<template name='shopping_admin'>
	<view style="display: flex;    height: 100%;">
		<!-- 商品分类-左边 -->
		<xinjin-header ref="headerRef" 
		:headerList="headerSearch.headerList" 
		hreaderTitle="商品分类" 
		but_img="@../../static/img/setting_000.png"
		@selectHeadBotton="formsubmit"
		@onSearch="headerSearchDirectory"
		@onUpdate="HeaderCallbackF"
		@onAdd="$refs.header_setting.open"
		@selectHeaderTop="onHeader"
		:showUpdate="true"
		:showAdd="true"
		:showSearch="true"
		v-if="isPop"
		></xinjin-header>
		<!-- end -->

		<!-- 商品信息-右边 -->
		<view class="box-infos font12"  :style="{width:isPop==true ? 'calc(100% - 180px)':'100%'}">
			<!-- 数据列表 -->
			<view class="content-box">
				<view class="boxsss40">
					<!-- 增加、删除 -->
					<view class="top-but menu-scroll-w" >
						<view class="top-but-box">
							<!-- 搜索 -->
							<view class=" sousouk">
								
								<userSelect 
								@onclickSelectUser="onclickSelectUser" 
								:showBilling="false" 
								:showSearch="false" 
								:showRoute="false" 
								:showGongYing="true"
								></userSelect>
							</view>
							<view class=" sousouk floatleft ">
								<view class="riskTitle">账号分组:</view>
								<view class="input_confirms maxwidth250 " >
									<uni-data-select
									:localdata="$routeData.getGroup()"
									v-model="search.group_id"
									placeholder="选择账号分组"
									class="color-e40318 "
									placeholder-class="placeholder-class"
									></uni-data-select>
								</view>
							</view>
							<view class=" sousouk floatleft ">
								<view class="riskTitle">筛选商品:</view>
								<view class="searchBox">
									<input
									:focus="search.focus"
									@blur="search.focus=false"
									v-model="search.word" 
									placeholder="输入商品名称 货位 ID 别称 首拼进行搜索"
									placeholder-class="placeholder-class"
									@confirm="$common.noMultipleClicks('searchBut',searchBut)"
									@input="searchBut()"
									class="search-ipu "
									/>
									<view class="delete-ipu" v-if="search.word!=''" @click="search.word='',search.focus=false">
										<img src="../../static/img/delete-1.png"  ></img>
									</view>
								</view>
							</view>
							<button @click="searchReset" 
							class=" search-but  color1" 
							>
								<img src="../../static/img/search.png" class="ico"></img>
								刷新
							</button>
							
							<!-- bjdj_money= !bjdj_money -->
							<button 
							@click="test"
							class="leftBut   color2" 
							>
								{{bjdj_money==false ? '编辑等级价格':'退出价格编辑'}}
							</button>
							
							<button 
							@click="bjkc_money= !bjkc_money"
							class="leftBut   color3" 
							>
								{{bjkc_money==false ? '编辑库存':'退出库存编辑'}}
							</button>
							
							<button class="leftBut  color4"
							@click="openActionSheets(resData.list[TabcheckedIndex],TabcheckedIndex,$event)"
							v-if="TabcheckedIndex>=0"
							>
								更多操作
							</button>
							
							
							<button
							@click="addShow()"
							class="leftBut   color5" 
							>
								增加(手动模式)
							</button>
							
							<button
							@click="addGoods()"
							class="leftBut   color6" 
							>
								增加(商品ID模式)
							</button>
							
							
							<button
							@click="$refs.excel_r.open()"
							class="leftBut   color7" 
							>
								增加(Excel模式)
							</button>
							
							<button
							@click="$my_excel.goods(resData.list,false)"
							class="nowBut font12 color7"
							>
								导出
							</button>
							
						</view>
						
					</view>

					<table v-if="showTab" id="goods_goods">
						<!-- 表头 -->
						<thead>
							<tr >
								<th class="centers ">
									<checkbox
										border-color="#333333" activeborderColor="#333333" activeBackgroundColor="#333"
										:checked="checkbox.select" 
										@click="choose_all"
										style="transform:scale(0.7);"
									/>
									
								</th>
								<th class="centers" v-if="bjkc_money==false && bjdj_money==false">
									id
								</th>
								<th class="centers " v-if="bjkc_money==false && bjdj_money==false">
									<view class="centers flex">
										<view>图</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='img_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='img_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
								
								<th class="centers "   >
									商品
								</th>
								
								<th class="centers  " v-if="bjdj_money==false && bjkc_money==false"
								@click="$common.changeColumnColor('goods_goods',0)"
								>
									<view class=" flex">
										<view>货位</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='position_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='position_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
								
								<th class="centers " v-if="bjkc_money"
								@click="$common.changeColumnColor('goods_goods',1)">
									库存上限
								</th>
								
								<th class="centers " v-if="bjkc_money"
								@click="$common.changeColumnColor('goods_goods',2)">
									库存下限
								</th>
								
								<th class="centers "
								@click="$common.changeColumnColor('goods_goods',3)">
									<view class="centers flex">
										<view>库存</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='risk_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='risk_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
								
								<th class="centers  " v-if="bjdj_money==false && bjkc_money==false"
								@click="$common.changeColumnColor('goods_goods',4)">
									<view class="centers flex" :title="$global.title.m40">
										
										<view>销量</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='sales_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='sales_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',5)">
									<view class="centers flex">
										<view>裸价</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='bare_money_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='bare_money_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',6)">
									<view class="centers flex">
										
										<view>进价</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='jinhuojia_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='jinhuojia_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
								
								<th 
								@click="$common.changeColumnColor('goods_goods',7)">
									<view class="centers flex">
										
										<view>批价</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='money_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='money_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
								
								<th v-if="bjdj_money" class="centers "
								@click="$common.changeColumnColor('goods_goods',8)">
									利润
								</th>
								<th class="centers "@click="$common.changeColumnColor('goods_goods',71)">
									赠送积分
								</th>
								<th class="centers "@click="$common.changeColumnColor('goods_goods',72)">
									下单备注
								</th>
								<th class="centers " v-if="bjdj_money" style="width: 100px;">
									商品备注
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',9)">
									<view class="centers flex">
										零售
									</view>
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',10)">
									<view class="centers flex">
										{{$routeData.GetLevelItem('1')['text']}}
									</view>
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',11)">
									<view class="centers flex">
										{{$routeData.GetLevelItem('2')['text']}}
									</view>
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',12)">
									<view class="centers flex">
										{{$routeData.GetLevelItem('3')['text']}}
									</view>
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',13)">
									<view class="centers flex">
										{{$routeData.GetLevelItem('4')['text']}}
									</view>
								</th>
								
								<th class="centers " v-if="bjdj_money"
								@click="$common.changeColumnColor('goods_goods',14)">
									<view class="centers flex">
										{{$routeData.GetLevelItem('5')['text']}}
									</view>
								</th>
								
								
								<th class="centers ">
									<view class="centers flex">
										<view>上架状态</view>
										<view class="sort-button ">
											<view class="desc"  @click="sort.value='grounding_desc',loadData(true);"></view>
											<view class="asc"   @click="sort.value='grounding_asc',loadData(true);"></view>
										</view>
									</view>
								</th>
							</tr>
						</thead>
						<tbody>
							<!-- 内容 -->
							<checkbox-group @change="checkbox_change" style="display: contents;">
							<tr v-for="(item,index) in resData.list"
							class=""
							:key="index" 
							:class="TabcheckedIndex == index || checkbox.checkbox_status.includes(item.id) ? 'goods-list-select':''"
							@click="TabcheckedIndex = index"
							>
								<td class="centers">
									<checkbox  class="centers  font12 "
										:value="item.id.toString()" 
										border-color="#333333" activeborderColor="#333333" 
										activeBackgroundColor="#333"
										:checked="checkbox.checkbox_status.includes(item.id)" 
										style="transform: scale(0.7);margin: auto;display: flex;"
									/>
								</td>
								
								<td class="centers" 
								v-if="bjkc_money==false && bjdj_money==false" 
								@click="$common.setClipboardData(item.id)"
								>
									<view class="margin">{{item.id}}</view>
								</td>
								
								<td  
								class="centers alter  font12" 
								v-if="item.img && item.img.length>0 && bjkc_money==false && bjdj_money==false" 
								@click="imageOpen(false,index)" >
									图{{item.img.length}}
								</td>
								
								<td  v-if="item.img &&  item.img.length==0 && bjkc_money==false && bjdj_money==false" class="centers "></td>

								<td   class="centers flex1 relative " :title="item.id">
									<view>
										<view class="flex font12">
											<view 
												v-if="item.plan_max_out.status"
												class="gift"
											>
											满送
											</view>
											<view 
												v-if="item.plan.status"
												class="gift"
											>
											秒杀
											</view>
											<countdown
											:startTime="item.plan.data.now_date" 
											:endTime="item.plan.data.end_time" 
											v-if="item.plan.status==true" 
											 />
											<countdown
											:startTime="item.plan_max_out.data.data.now_date" 
											:endTime="item.plan_max_out.data.data.end_time" 
											v-else-if="item.plan_max_out.status==true" 
											 />
										</view>
										<!-- 商品名称-输入框 -->
										<!-- <textarea :auto-height="true"  maxlength="-1" 
										style="height: auto;"
										></textarea> -->
										<input class="white-space goodsNameColor  font14"
										v-model="item.name" 
										@confirm="$req.updateGoodsName(item.id,item.name),item.GoodsClickFocus=false"/>
										<text class="input-measure">{{item.name}}</text>
										
																	
										<view class="back_data">
											<image src="/static/goods/score.png"
											class="ico" v-if="item.isScore==1"
											:title="$global.title.m30"
											></image>
											
											<image src="/static/img/disabled.png"
											class="ico" v-if="item.disabled.status==true"
											:title="$global.title.m36"
											></image>
										</view>
										
									</view>
								</td>

								<td  class="centers cursor col-0" :title="item.id" style="width: 100px;" 
								v-if="bjdj_money==false && bjkc_money==false"
								>
									<input
									:auto-height="true"
									v-model="item.position" 
									@confirm="$routeData.updatePosition(item.id,item.position)"
									class="white-space goodsNameColor font12"/>
								</td>

								<!-- 上限 -->
								<td class="centers col-1" v-if="bjkc_money" >
									<input
									:auto-height="true"
									v-model="item.margin_end" 
									@confirm="$routeData.updateMarginMode(item.id,item.margin_end,2)"
									class="centers white-space  font12"
									 :style="{color:item.margin_end<=0 ? '#ff0000':''}"
									/>
								</td>
								
								<!-- 下限 -->
								<td class="centers col-2" v-if="bjkc_money" >
									<input
									:auto-height="true"
									v-model="item.margin_start" 
									@confirm="$routeData.updateMarginMode(item.id,item.margin_start,1)"
									class="centers white-space  font12"
									 :style="{color:item.margin_start<=0 ? '#ff0000':''}"
									/>
								</td>
								
								<!-- 库存 -->
								<td  class="cursor col-3" >
									<view :title="item.check_date+''+$global.title.m15+'|'+$global.title.m28"  v-if="item.check==true" >
										<input
										:auto-height="true"
										v-model="item.margin" 
										@confirm="$routeData.updateMargin(item.id,item.margin)"
										class="centers white-space  font12"
										:style="{color:parseInt(item.margin)>0 && parseInt(item.margin_start)<parseInt(item.margin) ? '#2ab100':'#ff0000'}"
										/>
									</view>
								
									<view :title="$global.title.m28" v-if="item.check==false">
										<input
										:auto-height="true"
										v-model="item.margin" 
										@confirm="$routeData.updateMargin(item.id,item.margin)"
										class="centers white-space  font12"
										:style="{color:parseInt(item.margin)<=0  ? '#ff0000':''}"
										/>
									</view>
								</td>
								
								<td class="centers  font12 col-4" :title="item.sales_count" 
								v-if="bjdj_money==false && bjkc_money==false"
								>
									{{$common.formatNumber(item.sales_count)}}
								</td>
								
								<!-- 裸价 -->
								<td class="centers colorGoodsMoney col-5" :title="$global.title.m28" v-if="bjdj_money">
									<input
									:auto-height="true"
									v-model="item.bare_money" 
									@confirm="$routeData.updateBareMoney(item.id,item.bare_money)"
									class="centers white-space  font12"
									 :style="{color:item.bare_money<=0 ? '#ff0000':''}"
									/>
								</td>

								<td class="centers colorGoodsMoney col-6" :title="$global.title.m28" v-if="bjdj_money">
									<input
									:auto-height="true"
									v-model="item.jinhuojia" 
									@confirm="$routeData.updateJinhuojia(item.id,item.jinhuojia)"
									class="centers white-space  font12"
									 :style="{color:item.jinhuojia<=0 ? '#ff0000':''}"
									/>
								</td>

								<td class="centers colorGoodsMoney col-7" v-if="item.plan.status==false "
								:title="$global.title.m28">
									<input
									:auto-height="true"
									v-model="item.pifajia" 
									@confirm="$routeData.updatePifajia(item.id,item.pifajia)"
									class="centers white-space  font12"
									:style="{color:item.pifajia<=0 ? '#ff0000':''}"
									/>
								</td>
								
								<!-- 有活动下的批发价 -->
								<td class="centers colorGoodsMoney col-7" v-if="item.plan.status==true ">
									<view class="flex centers font12">
										<view class="m-price " >¥{{item.pifajia}}</view>
										<view class="coupon-tip">¥{{item.plan.data.money}}</view>
									</view>
								</td>


								<td class="centers colorGoodsMoney col-8" 
								v-if="bjdj_money"
								>
									<view class="flex font12">
										<view>
											润:￥{{Math.round((item.pifajia - item.jinhuojia)*100)/100}}
										</view>
										<view style="margin-left: auto;"
										:style="{color:Math.round(((item.pifajia - item.jinhuojia)/item.pifajia)*100)<=5 ? '#ff0000':'#2ab100'}"
										>
											率:{{Math.round(((item.pifajia - item.jinhuojia)/item.pifajia)*100)}}%
										</view>
									</view>
								</td>
								<!-- 积分 -->
								<td class="centers  col-71" >
									<input
									:auto-height="true"
									v-model="item.score" 
									@confirm="$routeData.updateScore(item.id,item.score)"
									class="centers white-space  font12"
									:style="{color:item.score>0 ? '#2ab100':''}"
									/>
								</td>
								<!-- 下单备注 -->
								<td class="centers  col-72" >
									<view class="centers" :class="item.tipmsgType==0 ? 'high':'ff2626'"> 
										{{item.tipmsgType == 0?'可选':'必填'}}
									</view>
								</td>
								<!-- 备注 -->
								<td class="centers " v-if="bjdj_money">
									<input
									style="min-width: 150px;"
									:auto-height="true"
									v-model="item.descr" 
									@confirm="$routeData.updateGoodsDescr(item.id,item.descr)"
									class="centers white-space  font12 w100px"
									/>
								</td>
								<!-- 零售 -->
								<td class="centers colorGoodsMoney col-9" 
								:title="'当前利润：￥'+(Math.round((item.petail_price - item.jinhuojia)*100)/100)"
								v-if="bjdj_money"
								>
									<input
									:auto-height="true"
									v-model="item.petail_price" 
									@confirm="$routeData.updatePetailPrice(item.id,item.petail_price)"
									class="centers white-space  font12"
									 :style="{color:item.petail_price<=0 ? '#ff0000':''}"
									/>
								</td>


								<!-- 等级价格 -->
								<td class="centers colorGoodsMoney col-10" v-if="bjdj_money" 
								:title="'当前利润：￥'+(Math.round((item.level1 - item.jinhuojia)*100)/100)"
								>
									<input
									:auto-height="true"
									v-model="item.level1" 
									@confirm="$routeData.updateLevelMoney(item.id,item.level1,1)"
									class="centers white-space  font12"
									 :style="{color:item.level1<=0 ? '#ff0000':''}"
									/>
								</td>

								<!-- 等级价格 -->
								<td class="centers colorGoodsMoney col-11" v-if="bjdj_money" 
								:title="'当前利润：￥'+(Math.round((item.level2 - item.jinhuojia)*100)/100)"
								>
									<input
									:auto-height="true"
									v-model="item.level2" 
									@confirm="$routeData.updateLevelMoney(item.id,item.level2,2)"
									class="centers white-space  font12"
									 :style="{color:item.level2<=0 ? '#ff0000':''}"
									/>
								</td>

								<!-- 等级价格 -->
								<td class="centers colorGoodsMoney col-12" v-if="bjdj_money" 
								:title="'当前利润：￥'+(Math.round((item.level3 - item.jinhuojia)*100)/100)"
								>
									<input
									:auto-height="true"
									v-model="item.level3" 
									@confirm="$routeData.updateLevelMoney(item.id,item.level3,3)"
									class="centers white-space  font12"
									 :style="{color:item.level3<=0 ? '#ff0000':''}"
									/>
								</td>


								<!-- 等级价格 -->
								<td class="centers colorGoodsMoney col-13" v-if="bjdj_money" 
								:title="'当前利润：￥'+(Math.round((item.level4 - item.jinhuojia)*100)/100)"
								>
									<input
									:auto-height="true"
									v-model="item.level4" 
									@confirm="$routeData.updateLevelMoney(item.id,item.level4,4)"
									class="centers white-space  font12"
									 :style="{color:item.level4<=0 ? '#ff0000':''}"
									/>
								</td>
								
								<!-- 等级价格 -->
								<td class="centers colorGoodsMoney col-14" v-if="bjdj_money" 
								:title="'当前利润：￥'+(Math.round((item.level5 - item.jinhuojia)*100)/100)"
								>
									<input
									:auto-height="true"
									v-model="item.level5" 
									@confirm="$routeData.updateLevelMoney(item.id,item.level5,5)"
									class="centers white-space  font12"
									 :style="{color:item.level5<=0 ? '#ff0000':''}"
									/>
								</td>
							
								
								<td class="centers  centers font12 cursor hover"
								:style="{color:item.mp_grounding==0 ? '#ff0000':'#2ab100'}"
								@click="()=>{
										$common.noMultipleClicks('fun_mp_grounding',fun_mp_grounding,index,item.mp_grounding==0?1:0)
								}"
								>
									{{item.mp_grounding==0 ? '未上架':'已上架'}}
								</td>
								
							</tr>
							
							
							</checkbox-group>
						</tbody>
					</table>
					

					
					<!-- 更多 TabcheckedIndex -->
					<view class="xd-main flex sticky-bottom" v-if="TabcheckedIndex>=0 && resData.list.length>0" >
						<!-- 单选商品的处理 -->
						<view class="w100 flex xd-box" style="overflow: visible;">
							
							
							<button class="but but-color1 color1"
							v-if="checkUpdate.Mode==-1"
							:disabled="isSelectAll==true"
							@click="Fun_alter(TabcheckedIndex,resData.list[TabcheckedIndex].number,resData.list[TabcheckedIndex].id)" 
							>
								设置/详细
							</button>
							
							<button class="but but-color1 color2"  
							v-if="checkUpdate.Mode==-1"
							:disabled="isSelectAll==true"
							@click="$refs.goods_card.open()">
								虚拟卡密管理
							</button>
							
							<button class="but but-color1 color2"  
							v-if="checkUpdate.Mode==-1"
							:disabled="isSelectAll==true"
							@click="OpenGoodsRecord(resData.list[TabcheckedIndex])">
								商品销售记录
							</button>
							
							<button class="but but-color1 color3" 
							v-if="checkUpdate.Mode==-1"
							 @click="imageOpen(false,TabcheckedIndex)"
							:disabled="isSelectAll==true"
							>
								商品图片管理
							</button>
					
							<button class="but but-color1 color4" 
							v-if="checkUpdate.Mode==-1"
							 @click="$req.printLabel(resData.list[TabcheckedIndex].id)"
							:disabled="isSelectAll==true"
							>
								商品标签打印
							</button>
							
							<button class="but but-color1 color5" 
							v-if="checkUpdate.Mode==-1"
							:disabled="isSelectAll==true"
							@click="createQrcode(resData.list[TabcheckedIndex].id)">
								商品二维码预览
							</button>
					
							<button class="but but-color1 color6" 
							v-if="checkUpdate.Mode==-1"
							:disabled="isSelectAll==true"
							 @click="getwxacodeunlimit(resData.list[TabcheckedIndex])">
								商品商城码预览
							</button>
							
							<button class="but but-color1 color7" 
							v-if="checkUpdate.Mode==-1"
							:disabled="isSelectAll==true"
							@click="$req.printPositionLabel(resData.list[TabcheckedIndex].position)">
								商品货位标签打印
							</button>
							
							
							<button class="but but-color1 color8"
							v-if="checkUpdate.Mode==-1"
							@click="goodsDisabledOpen()" 
							>
								商品独家销售管理
							</button>
							
							<button class="but color9"
							v-if="checkUpdate.Mode==-1"
							@click="openActionSheetMoney(resData.list[TabcheckedIndex],TabcheckedIndex,$event)"
							>
								批量修改价格
							</button>
							
							<button class="but but-color1 color10"
							@click="checkUpdate.Mode=1">
								指定用户分组可买
							</button>
							
							<view class="input_confirms maxwidth250" v-if="checkUpdate.Mode==1">
								<uni-data-select
								:localdata="$routeData.getGroup()"
								v-model="checkUpdate.value"
								placeholder="选择账号分组"
								class="color-e40318 floatleft"
								placeholder-class="placeholder-class"
								></uni-data-select>
							</view>
							<button class="but but-color1 color3"
							v-if="checkUpdate.Mode==1"
							@click="checkboxuserUpdateCheck()">
								确定保存
							</button>
							<button class="but but-color1 color5"
							
							v-if="checkUpdate.Mode==1"
							@click="checkUpdate.Mode=-1">
								取消
							</button>
							
							<button class="but but-color1 color1"
							@click="sendTipmsgType($event)">
								设置、取消【备注项】必填
							</button>
							
							<button class="but but-color1 color2"
							v-if="checkUpdate.Mode==-1"
							@click="openActionSheet(resData.list[TabcheckedIndex],TabcheckedIndex,$event)"
							>
								更多操作
							</button>
							
							<view class="flex margin-left gap10">
								<view class="flex margin nowrap" @click="GetSum('getMargin')" :title="sumData.getMargin.value">
									<text class="right3">库存：</text>
									<text class="alter">
										{{sumData.getMargin.value.length<=0?'计算':$common.formatNumber(sumData.getMargin.value)}}
									</text>
								</view>
								
								<view class="flex margin nowrap" @click="GetSum('getSales')" :title="sumData.getSales.value">
									<text class="right3">销量：</text>
									<text class="alter">
										{{sumData.getSales.value.length<=0?'计算':$common.formatNumber(sumData.getSales.value)}}
									</text>
								</view>
								
								<view class="flex margin nowrap" @click="GetSum('getJinjia')":title="'现有库存的商品进价合计：'+sumData.getJinjia.value">
									<text class="right3">进价：</text>
									<text class="alter">
										{{sumData.getJinjia.value.length<=0?'计算':$common.formatNumber(sumData.getJinjia.value)}}
									</text>
								</view>
								
								<view class="flex margin nowrap" @click="GetSum('getPifa')":title="'现有库存的商品批价合计：'+sumData.getPifa.value">
									<text class="right3">批价：</text>
									<text class="alter">
										{{sumData.getPifa.value.length<=0?'计算':$common.formatNumber(sumData.getPifa.value)}}
									</text>
								</view>
								
							</view>
						</view>
						
						
					</view>
					<!-- 更多 end -->
					
				</view>
				

				<pages  
				:sum="page.sum"
				:current="page.nowPage"
				@updatePage="updatePage"
				></pages>
			</view>
			<!-- 数据列表end -->
		</view>

		<!-- 修改别称的弹窗  选择商品 遮罩层 -->
		<uni-popup ref="goodsKeyword" type="center" title="选择商品以选中批量修改商品别称">
			<!-- 数据列表 -->
			<view class="content-box font12" >
				<view class="add-box">
					<view class="add-goods">
						<view class="riskTitle">搜索商品关键字:</view>
						<input 
						v-model="search.word" 
						@confirm="searchBut()"
						@input="searchBut()"
						class="pop-input" placeholder-class="placeholder-class" />
					</view>
					<view @click="$common.noMultipleClicks('searchBut',searchBut)"  class="add-but-com">
						<img src="../../static/img/search.png" class="ico"></img>
						搜索
					</view>
				</view>
				<view class="boxsss" >
					<table v-if="resData.list.length>0">
						<!-- 表头 -->
						<thead>
								<th  style="min-width: 20px;">
									<checkbox
										border-color="#333333" activeborderColor="#333333" activeBackgroundColor="#333"
										:checked="goodsKeywordData.checkbox.select" 
										@click="GoodsKeywordDataChooseAll"
										class=" "
									/>
									序
								</th>
								<th  class=" ">
									商品
								</th>
								<th  class=" ">
									关键词
								</th>
							</tr>
						</thead>
						<tbody>
							<checkbox-group @change="GoodsKeywordDataCheckboxChange" style="display: contents;">
							<!-- 内容 -->
							<tr v-for="(item,index) in resData.list" 
							:key="index"
							:class="goodsKeywordData.checkbox.checkbox_status.includes(item.id) ? 'goods-list-select':''"
							>
								<td  class=" ">
									<checkbox
										:value="item.id.toString()" 
										border-color="#333333" activeborderColor="#333333" activeBackgroundColor="#333"
										:checked="goodsKeywordData.checkbox.checkbox_status.includes(item.id)" 
									/>
									{{index+1}}
								</td>
								<td   @click="Fun_alter(index,item.number,item.id)" class="bb4e00 hover  ">
									{{item.name}}
								</td>
								<td  class="centers  ">
									{{item.keyword}}
								</td>
							</tr>
							</checkbox-group>
						</tbody>
					</table>
					<empty v-if="resData.list.length==0"></empty>
				</view>
				
				<pages 
				:sum="page.sum"
				:current="page.nowPage"
				@updatePage="updatePage"
				></pages>
			
				<view class="MpDiscountSelectGoodsBut">
					<view class="add-goods">
						<view>输入选中商品需要修改的关键词</view>
						
						<input 
						v-model="goodsKeywordData.keyword" 
						class="pop-input" placeholder-class="placeholder-class"/>
					</view>
					<view @click="$common.noMultipleClicks('GoodsKeywordDataUpdate',GoodsKeywordDataUpdate)"  class="add-but-com">
						<img src="../../static/img/goods-send.png" class="ico"></img>
						确定
					</view>
				</view>
			</view>
			<!-- 数据列表end -->
			
				
		</uni-popup>
		<!-- end -->
		
		<!-- 修改 商品所属 目录 遮罩层 -->
		<uni-popup ref="goodsMoveHeader" type="center"  @change="()=>{unclassifieds=false}" title="修改商品所属分类目录">
			<!-- 数据列表 -->
			<view class="box-infos font12">
				<view class="content-box" >
					<view class="boxsss40" >
						<view class="top-but menu-scroll-w">
							<view class="top-but-box">
								<view class="add-goods">
									<view class="riskTitle">搜索商品关键字:</view>
									<input 
									v-model="search.word" 
									@confirm="searchBut()"
									class="pop-input" placeholder-class="placeholder-class" />
								</view>
								<view @click="unclassifieds=false,$common.noMultipleClicks('searchBut',searchBut)"  class="add-but-com-0">
									<img src="../../static/img/search.png" class="ico"></img>
									检索全部
								</view>
								<view @click="unclassifieds=true,$common.noMultipleClicks('searchBut',searchBut)"  class="add-but-com-0">
									<img src="../../static/img/search.png" class="ico"></img>
									检索未分类的商品
								</view>
													
							</view>
							
						</view>
						<table v-if="resData.list.length>0">
							<!-- 表头 -->
							<thead>
								<tr >
									<th  class="">
										<view class="flex" style="min-width: 20px;">
											<checkbox
												border-color="#333333" activeborderColor="#333333" activeBackgroundColor="#333"
												:checked="goodsMoveHeader.checkbox.select" 
												@click="GoodsMoveHeaderChooseAll"
												class=""
											/>
											序
										</view>
									</th>
									<th   @click="Fun_alter(index,item.number,item.id)" class="">
										商品
									</th>
									<th  class="">
										当前目录
									</th>
								</tr>
							</thead>
							<tbody>
								<!-- 内容 -->
								<tr v-for="(item,index) in resData.list" 
								:key="index"
								:class="goodsMoveHeader.checkbox.checkbox_status.includes(item.id) ? 'goods-list-select':''"
								>
									<checkbox-group @change="GoodsMoveHeaderCheckboxChange" style="    display: contents;">
										
											<td  class="">
												<view class="flex">
													<checkbox
														:value="item.id.toString()" 
														border-color="#333333" activeborderColor="#333333" activeBackgroundColor="#333"
														:checked="goodsMoveHeader.checkbox.checkbox_status.includes(item.id)" 
														class=""
													/>
													{{index+1}}
												</view>
											</td>
											<td  class="bb4e00 hover " 
											@click="Fun_alter(index,item.number,item.id)"
											>
												{{item.name}}
											</td>
											
											<td  class="">
												{{item.directory_name}}
											</td>
									</checkbox-group>
								</tr>
							</tbody>
						</table>
						
						<!-- 暂无数据 -->
						<empty v-if="resData.list.length==0"></empty>
						<!-- end -->
					</view>
					
					
		
					<pages 
					:sum="page.sum"
					:current="page.nowPage"
					@updatePage="updatePage"
					></pages>
				
					<view class="MpDiscountSelectGoodsBut" >
						<view class="add-goods-bb" >
							<view>选中的商品移动至以下目录</view>
							<header_select
							 class="h100 justify"
							:nowAdd="false"
							:headerList="headerSearch.headerList" 
							@call_directory="GoodsMoveHeaderSelectListIndex"
							:directory_name="goodsMoveHeader.directoryName"
							:header_name="goodsMoveHeader.headerName"
							></header_select>
						</view>
						<view @click="GoodsMoveHeaderUpdate"  class="add-but-com-0">
							<img src="../../static/img/goods-send.png" class="ico"></img>
							确定
						</view>
						
						<view class="search-but back_color" @click="goodsAiToHeader">
							AI智能分类
						</view>
						
					</view>
					
				</view>
				
			</view>
			<!-- 数据列表end -->
			

		</uni-popup>
		<!-- end -->

		<!-- 图片管理 遮罩层 -->
		<uni-popup ref="image" type="center" :title="uploadImg.name+' 图片管理'" minWidth="auto">
			<view style="height: calc(100% - 170px);display: flex;min-height: 400px;    width: 880px;">
				<view class="menu-scroll" style="padding-bottom: 40px;">
					<view class="goodsAddBox " v-if="moveElementPositionData==false">
						<view class="margin">
							<img  src="../../static/img/goodsAdd.png" class="goodsAddImage" @click="chooseImage"></img>
							<text class="tips">上传图片</text>
						</view>
					</view>
					<view v-for="(item,index) in previewImageData.list" :key="index" class="image-box relative">
						<!-- 编辑排序 -->
						<view class="left-right" v-if="moveElementPositionData">
							<image 
							class="left margin-right" 
							src="/static/img/left.png"
							@click="previewImageData.list=$global.moveElementPosition(previewImageData.list,item.id,'left')"
							></image>
							
							<image 
							class="right mainLeft" 
							src="/static/img/right.png"
							@click="previewImageData.list=$global.moveElementPosition(previewImageData.list,item.id,'right')"
							></image>
						</view>
						<img :src="item.reduce" class="image" @click="previewImage(index,previewImageData.list)"></img>
				
						<view class="flex" v-if="moveElementPositionData==false">
							<view v-if="item.type!='tmp'" 
							class="de margin-right" 
							:class="item.connive==0 ?'c000':'alter'" 
							@click="$common.noMultipleClicks('imgConnive',imgConnive,index)"
							>设为封面</view>
							
							<view v-if="item.type!='tmp'"
							class="de mainLeft" 
							:class="item.connive==0 ?'c000':'alter'" 
							@click="$routeData.GetGoodsImgInfo(item.id)"
							>详细</view>
						</view>
						<text selectable="true"  v-if="item.type=='tmp' && moveElementPositionData==false" class="uploadNot" @click="previewImage(index,previewImageData.list)">
							等待上传...
						</text>

						<view class="deleteImg" 
						v-if="moveElementPositionData==false"
						@click="$common.noMultipleClicks('fun_img_de',fun_img_de,index)">
							<image  src="/static/img/close.png" class="alter_sure"></image>
						</view>
						
					</view>
					
				</view>
			</view>
			
			<view class="fanyeImageBox">
				<view class="fanyeImage ">
					<view class="alter justify" @click="PageTurningOpen('subtract')"
					v-if="moveElementPositionData==false"
					>
						<img  src="../../static/goods/web__left.png" class="goodsAddImage"></img>
						上一个商品
					</view>
					
					<button class="add_color up font12" 
					v-if="moveElementPositionData==false"
					@click="$common.noMultipleClicks('fun_uploadImg',fun_uploadImg)"
					>
					确定上传图片
					</button>
					
					<button class="back_colo up font12"
					v-if="moveElementPositionData==true"
					@click="moveElementPositionData=false"
					>
					取消
					</button>
					
					<button class="add_color  up font12"
					v-if="moveElementPositionData==true"
					@click="moveElementPositionData=false,$common.noMultipleClicks('moveElementPositionFun',moveElementPositionFun)"
					>
					保存排序
					</button>
					
					<view class="alter justify" @click="PageTurningOpen('add')"
					v-if="moveElementPositionData==false"
					>
						<img  src="../../static/goods/web__right.png" class="goodsAddImage"></img>
						下一个商品
					</view>
				</view>
				<view class="fanyeImage " v-if="moveElementPositionData==false">
					<view class="margin alter justify" 
					@click="$common.noMultipleClicks('reuseGoodsImage',reuseGoodsImage)">
						<img  src="../../static/goods/copy.png" class="goodsAddImage"></img>
						复用商品单张图片
					</view>
					
				
					<view class="margin alter justify" 
					@click="moveElementPositionData=true" v-if="moveElementPositionData==false"
					>
						<img  src="../../static/img/update_000.png" class="goodsAddImage"></img>
						编辑排序
					</view>
				
					<view class="margin alter justify" 
					@click="$common.noMultipleClicks('readImageFile',readImageFile)">
						<img  src="../../static/goods/url.png" class="goodsAddImage"></img>
						网络链接导入图片
					</view>
					
					<view class="margin alter justify" 
					@click="$common.noMultipleClicks('reuseGoodsImageAll',reuseGoodsImageAll)">
						<img  src="../../static/goods/copy.png" class="goodsAddImage"></img>
						复用商品全部图片
					</view>
					
					
					<view class="margin alter justify" 
					@click="$refs.uploadImage.imageOpen(uploadImg.name,previewImageData.list,uploadImg.goods_id)">
						<img  src="../../static/goods/url.png" class="goodsAddImage"></img>
						图片库上传
					</view>
				</view>
								
			</view>
							
		</uni-popup>
		<!-- end -->

		<!-- 商品记录  -->
		<uni-popup ref="goods_record" type="center" title="商品销售记录">
			<view class="sp_records">
				<goods_record
				 :isPagesOpen="true"
				 :showSearchClose="false"
				:OnPageSearch="pageSearch.value"
				@goodsRecordClose="goodsRecordClose"
				></goods_record>
			</view>   
		</uni-popup>
		<!-- end -->

		<!-- 数据导入  -->
		<uni-popup ref="excel_r" type="center" title="数据导入">

			<excel
			 uploadTypeName="goods_add"
			></excel>

		</uni-popup>
		<!-- end -->


		<!-- 商品增加/修改遮罩层 -->
		<uni-popup ref="popup" type="center" title="商品信息" class="" width="auto">
			<view style="overflow: auto;height: 100%;">
				<view class="goods-edit-pc">
					<view class="edit-main">
						<!-- 商品名称区块 -->
						<view class="add-box">
							
							<view class="add-goods flex1 flex floatleft">
								<text class="riskTitle"><text class="status0">*</text>商品名称：</text>
								<input 
									v-model="add.data.name" 
									class="search-ipu"></input>
							</view>
							<view class="add-goods-flex" 
								v-if="add.data.directory_name !=''"
								@click="$common.noMultipleClicks('fun_name_create',fun_name_create)">
								<view class="name-create">{{add.data.types+add.data.directory_name+'('+add.data.brand+')'}}</view>
							</view>
						</view>
						<!-- 供货商家  商品品牌-->
						<view class="add-box">
							
							<select_input
								title="供货商家"
								v-model="add.data.gonghuoName"
								:searchList="selectUserVenderData.list"
								@addSelectInput="$refs.page_admin.open"
								:showAddBut="true"
								:bitian="true"
								class="form-item floatleft flex"
							></select_input>
							
							<select_input
								title="商品品牌"
								v-model="add.data.brand"
								:searchList="selectBrandData.list"
								:bitian="true"
								class="form-item floatleft flex"
							></select_input>
						</view>
						
						<!-- 分类 -->
						<view class="add-box" v-show="headerShrink">
							<header_select class="header-select "
								style="flex: 1;"
								:AiAuto="true"
								:AiAutoGoodsName="add.data.name"
								:headerList="headerSearch.headerList" 
								@call_directory="call_directory"
								:directory_id="add.data.directory"
								:header_id="add.data.header"
								@addHeader="$refs.header_setting.open"
								@addDirectory="$refs.header_setting.open">
							</header_select>
						</view>
					
						<!-- 展开分类设置 -->
						<view class="xiala" 
						@click="headerShrink = !headerShrink"
						:class="headerShrink==false ? 'xiala1':'xiala2'"
						>
							{{headerShrink==false ? '展开分类设置':'收缩'}}
						</view>

						<!-- 适配车型 商品货位 -->
						<view class="add-box-goods">
							<select_input
								title="适配车型"
								v-model="add.data.types"
								:searchList="selectTypesData.list"
								class="form-item floatleft flex"></select_input>
							
							<view class="add-goods floatleft">
								<text class="riskTitle">商品货位：</text>
								<input 
									v-model="add.data.position"   
									placeholder="A53-01-03"
									class="search-ipu"></input>
							</view>
							
							<view class="add-goods floatleft">
								<text class="riskTitle">指定分组可购买：</text>
								<view class="maxwidth250">
									<uni-data-select
										:localdata="$routeData.getGroup()"
										v-model="add.data.group_id"
										placeholder="选择账号分组"
										class="search-ipu "></uni-data-select>
								</view>
							</view>
								<text class="form-tip">(注:非此分组内用户禁止购买、不可见)</text>
						</view>


						<!-- 库存最低 库存最高 整件单位 个体单位 整件数量 -->
						<view class="add-box-goods" v-show="kucunShrink">
							<view class="flex floatleft">
								<text selectable="true" class="riskTitle" >
									库存最低：
								</text>
								<input 
								v-model="add.data.margin_start"   
								 placeholder="2"
								 placeholder-class="placeholder-class"
								class="search-ipu "  />
								
							</view>
							<view class="flex floatleft">
								<text selectable="true" class="riskTitle" >
									库存最高：
								</text>
								<input 
								v-model="add.data.margin_end"   
								 placeholder="2"
								 placeholder-class="placeholder-class"
								class="search-ipu "  />
							</view>
							
							<view class="flex floatleft">
								<text selectable="true" class="riskTitle" >
									整件单位：
								</text>
								<input 
								v-model="add.data.units_sumName"   
								 placeholder="件"
								 placeholder-class="placeholder-class"
								class="search-ipu "   />
							</view>
							<view class="flex floatleft">
								<text selectable="true" class="riskTitle" >
									个体单位：
								</text>
								<input 
								v-model="add.data.units"   
								 placeholder="条"
								 placeholder-class="placeholder-class"
								class="search-ipu "   />
							</view>
							<view class="flex floatleft">
								<text selectable="true" class="riskTitle" >
									整件数量：
								</text>
								<input 
								type="number"
								v-model="add.data.units_count"  
								 placeholder="5" 
								 placeholder-class="placeholder-class"
								class="search-ipu "   />
							</view>
						</view>

						<!-- 展开库存设置 -->
						<view class="xiala" 
						@click="kucunShrink = !kucunShrink"
						:class="kucunShrink==false ? 'xiala1':'xiala2'"
						>
							{{kucunShrink==false ? '展开库存设置':'收缩'}}
						</view>
						<!-- 裸货价格 进货价格 批发价格 零售价格  -->
						<view class="add-box-goods">
							<view class="flex floatleft">
									
								<text selectable="true" class="riskTitle" >
									裸货价格：
								</text>
								<input 
								type="number"
								v-model="add.data.bare_money"   
								 placeholder="20"
								 placeholder-class="placeholder-class"
								class="search-ipu "   />
							</view>
							<view class="flex floatleft">
									<text selectable="true" class="riskTitle" >
										进货价格：
									</text>
									<input 
									type="number"
									v-model="add.data.jinhuojia"   
									 placeholder="20"
									 placeholder-class="placeholder-class"
									class="search-ipu "   />
							
							</view>
							<view class="flex floatleft">
								<text selectable="true" class="riskTitle" >
									批发价格：
								</text>
								<view class="search-ipu-goods " >
									<input
									class="justify moneyProfitLeft"
									type="number"
									v-model="add.data.pifajia"   
									@input="inputAllow"
									placeholder="25"
									placeholder-class="placeholder-class"
									/>
									<view class="justify moneyProfitRight">
										<view class="flex">
											<view>
												润:￥{{Math.round((add.data.pifajia - add.data.jinhuojia)*100)/100}}
											</view>
											<view style="margin-left: auto;color: #2ab100;">
												率:{{Math.round(((add.data.pifajia - add.data.jinhuojia)/add.data.pifajia)*100)}}%
											</view>
										</view>
									</view>
								</view>
						
								
							</view>
							<view class="flex floatleft">		
								<text selectable="true" class="riskTitle" >
									零售价格：
								</text>
								<view class="search-ipu-goods " >
									<input
										class="justify moneyProfitLeft"
										type="number"
										v-model="add.data.petail_price"   
										@input="inputAllow"
										placeholder="25"
										placeholder-class="placeholder-class"
									/>
									<view class="justify moneyProfitRight">
										<view class="flex">
											<view>
												润:￥{{Math.round((add.data.petail_price - add.data.jinhuojia)*100)/100}}
											</view>
											<view style="margin-left: auto;color: #2ab100;">
												率:{{Math.round(((add.data.petail_price - add.data.jinhuojia)/add.data.petail_price)*100)}}%
											</view>
										</view>
									</view>
								</view>
							</view>

						</view>

						<!-- 最低销售 各个级别价格  -->
						<view class="add-box-goods" v-show="moneyShrink">
							<!-- 最低销售 -->
							<view class="flex floatleft">
								
								<text selectable="true" class="riskTitle" >
									最低销售：
								</text>
								<view class="search-ipu-goods " >
									<input 
									type="number"
									v-model="add.data.allow"   
									 placeholder="20"
									 placeholder-class="placeholder-class"
									class=" moneyProfitLeft"  />
								
									<view class="justify moneyProfitRight">
										<view class="flex">
											<view>
												润:￥{{Math.round((add.data.allow - add.data.jinhuojia)*100)/100}}
											</view>
											<view style="margin-left: auto;color: #2ab100;">
												率:{{Math.round(((add.data.allow - add.data.jinhuojia)/add.data.allow)*100)}}%
											</view>
										</view>
									</view>
									
								
								</view>
							
										
							</view>
							
						
							<view class="flex floatleft"  >
									<text selectable="true" class="riskTitle" >
										{{$routeData.GetLevelItem('1')['text']}}：
									</text>
									
									<view class="search-ipu-goods " >
										<input 
										type="number"
										v-model="add.data.level1"   
										 placeholder="20"
										 placeholder-class="placeholder-class"
										class="justify moneyProfitLeft"  />
										
										<view class="justify moneyProfitRight" style="width: 170px;">
											<view class="flex">
												<view>
													润:￥{{Math.round((add.data.level1 - add.data.jinhuojia)*100)/100}}
												</view>
												<view style="margin-left: auto;color: #2ab100;">
													率:{{Math.round(((add.data.level1 - add.data.jinhuojia)/add.data.level1)*100)}}%
												</view>
											</view>
										</view>
										
										
									</view>
							</view>	
						
							<view class="flex floatleft" >
									<text selectable="true" class="riskTitle" >
										{{$routeData.GetLevelItem('2')['text']}}：
									</text>
									
									<view class="search-ipu-goods ">
										<input 
										type="number"
										v-model="add.data.level2"   
										 placeholder="20"
										 placeholder-class="placeholder-class"
										class="justify moneyProfitLeft"  />
										
										<view class="justify moneyProfitRight"style="width: 170px;">
											<view class="flex">
												<view>
													润:￥{{Math.round((add.data.level2 - add.data.jinhuojia)*100)/100}}
												</view>
												<view style="margin-left: auto;color: #2ab100;">
													率:{{Math.round(((add.data.level2 - add.data.jinhuojia)/add.data.level2)*100)}}%
												</view>
											</view>
										</view>
									
										
									</view>
							</view>	
								
							<view class="flex floatleft" >
									<text selectable="true" class="riskTitle" >
										{{$routeData.GetLevelItem('3')['text']}}：
									</text>
									<view class="search-ipu-goods " >
										<input 
										type="number"
										v-model="add.data.level3"   
										 placeholder="20"
										 placeholder-class="placeholder-class"
										class="justify moneyProfitLeft"  />
										
										<view class="justify moneyProfitRight"style="width: 170px;">
											<view class="flex">
												<view>
													润:￥{{Math.round((add.data.level3 - add.data.jinhuojia)*100)/100}}
												</view>
												<view style="margin-left: auto;color: #2ab100;">
													率:{{Math.round(((add.data.level3 - add.data.jinhuojia)/add.data.level3)*100)}}%
												</view>
											</view>
										</view>
									
									
									</view>
							</view>	
								
							<view class="flex floatleft" >
									<text selectable="true" class="riskTitle" >
										{{$routeData.GetLevelItem('4')['text']}}：
									</text>
									<view class="search-ipu-goods ">
										<input 
										type="number"
										v-model="add.data.level4"   
										 placeholder="20"
										 placeholder-class="placeholder-class"
										class="justify moneyProfitLeft"  />
										
										<view class="justify moneyProfitRight"style="width: 170px;">
											<view class="flex">
												<view>
													润:￥{{Math.round((add.data.level4 - add.data.jinhuojia)*100)/100}}
												</view>
												<view style="margin-left: auto;color: #2ab100;">
													率:{{Math.round(((add.data.level4 - add.data.jinhuojia)/add.data.level4)*100)}}%
												</view>
											</view>
										</view>
									
									</view>
								
								
							</view>
							<!-- 更多价格设置 -->
							<view class="flex floatleft" >
								
								
									
									<text selectable="true" class="riskTitle" >
										{{$routeData.GetLevelItem('5')['text']}}：
									</text>
									<view class="search-ipu-goods " >
										<input 
										type="number"
										v-model="add.data.level5"   
										 placeholder="20"
										 placeholder-class="placeholder-class"
										class="justify moneyProfitLeft"  />
										
										<view class="justify moneyProfitRight"style="width: 170px;">
											<view class="flex">
												<view>
													润:￥{{Math.round((add.data.level5 - add.data.jinhuojia)*100)/100}}
												</view>
												<view style="margin-left: auto;color: #2ab100;">
													率:{{Math.round(((add.data.level5 - add.data.jinhuojia)/add.data.level5)*100)}}%
												</view>
											</view>
										</view>
									
									</view>
								
								
								
							</view>
							
							<view class="form-tip">对于输入设定【-0.01】的商品，即是客户默认使用批发价</view>
						</view>

						<!-- 展开更多价格设置 -->
						<view class="xiala" 
						@click="moneyShrink = !moneyShrink"
						:class="moneyShrink==false ? 'xiala1':'xiala2'"
						>
							{{moneyShrink==false ? '展开更多价格设置':'收缩'}}
						</view>

						<!-- 积分控制 -->
						<view class="add-box-goods">
							<view  class="flex floatleft ">
								<text selectable="true" class="riskTitle" >
									用户购买赠送：
								</text>
								<input 
								type="number"
								:title="$global.title.m35"
								v-model="add.data.score"  
								 placeholder="1" 
								 placeholder-class="placeholder-class"
								class="search-ipu"  />
								
								<text selectable="true" class="riskTitle" >
									/积分
								</text>
							</view>
						
						
							<view class="flex floatleft " v-if="add.update_id.length>0">
								<view class="flex align-items relative">
									<text selectable="true" class="riskTitle" >
										用户使用：
									</text>
									<input 
									:title="$global.title.m30"
									type="number"
									v-model="add.data.goodsScore"  
									 placeholder="1" 
									 placeholder-class="placeholder-class"
									class="search-ipu"  />
									<text selectable="true" class="riskTitle" >
										积分可进行兑换
									</text>
									
									<view class="back_data">
										<image src="/static/goods/score.png"
										class="ico" v-if="add.data.isScore==1"
										:title="$global.title.m30"
										></image>
									</view>
								</view>
								
								
							</view>
							
							<view
							@click="$req.sendGoodsScore(add.update_id,add.data.goodsScore,(res)=>{add.data.isScore=res.value})"
							class="leftBut floatleft  color3 font12"
							>
								{{add.data.isScore==1 ?'取消为积分商品':'设置为积分商品'}}
							</view>
						</view>

						<!-- 附加字段设置 -->
						<view class="add-box-goods" v-show="AccountShrink">
								<view class="flex floatleft">
									<text selectable="true" class="riskTitle" >
										字段名称：
									</text>
									<view class="search-ipu " >
										<input 
										v-model="add.data.account"   
										 placeholder="充值账号"
										 placeholder-class="placeholder-class"
										class=" search-ipu "  />
									</view>
								</view>
								<view class="flex floatleft">
									<text selectable="true" class="riskTitle" >
										字段提示：
									</text>
									<view class="search-ipu " >
										<input 
										v-model="add.data.tipmsg"   
										 placeholder="QQ号/手机号"
										 placeholder-class="placeholder-class"
										class=" search-ipu "  />
									</view>
								</view>
								<view class="flex floatleft">
									<text selectable="true" class="riskTitle" >
										第三方ID：
									</text>
									<view class="search-ipu " >
										<input 
										v-model="add.data.tmp"   
										 placeholder="QQ号/手机号"
										 placeholder-class="placeholder-class"
										class=" search-ipu "  />
									</view>
								</view>
								<view
								@click="sendTipmsgTypes(add.update_id,add.data.tipmsgType)"
								class="leftBut floatleft  color3 font12"
								>
									{{add.data.tipmsgType==1 ?'取消备注为下单的必填项':'设置备注为下单的必填项'}}
								</view>
								
						</view>
						
						<!-- 展开附加字段设置 -->
						<view class="xiala" 
						:class="AccountShrink==false ? 'xiala1':'xiala2'"
						@click="AccountShrink = !AccountShrink"
						>
							{{AccountShrink==false ? '展开附加字段设置':'收缩'}}
						</view>
						<!-- 附加备注 -->
						<view class="add-box-goods" >
							<view class=" flex floatleft">
								<text selectable="true" class="riskTitle" >
									附加备注：
								</text>
								<view class="search-ipu " >
									<input  
									v-model="add.data.descr"  
									 placeholder="质保一年"
									 placeholder-class="placeholder-class"
									class="search-ipu"  />
								</view>
							</view>
						</view>


						<!-- 跳转第三方设置 -->
						<view class="add-box-goods" v-if="gotoMt">
							
							<!-- H5链接 -->
							<view class=" flex floatleft">
								<text selectable="true" class="riskTitle" >
									H5链接：
								</text>
								<input  
								v-model="add.data.h5"  
								 placeholder="用户可直接访问链接"
								 placeholder-class="placeholder-class"
								class="search-ipu-goods "  />
							</view>
							<!-- 呼起协议 -->
							<view class=" flex floatleft">
								<text selectable="true" class="riskTitle" >
									呼起协议：
								</text>
								<input  
								v-model="add.data.app"  
								 placeholder="引导用户唤起美团客户端访问链接"
								 placeholder-class="placeholder-class"
								class="search-ipu-goods "  />
							</view>
							<!-- 小程序ID -->
							<view class=" flex floatleft">
								<text selectable="true" class="riskTitle" >
									小程序ID：
								</text>
								<input  
								v-model="add.data.mp_id"  
								 placeholder="AppID(小程序ID)"
								 placeholder-class="placeholder-class"
								class="search-ipu-goods "  />
							</view>
							<!-- 小程序唤起路径 -->
							<view class=" flex floatleft">
								<text selectable="true" class="riskTitle" >
									小程序唤起路径：
								</text>
								<input  
								v-model="add.data.mp_path"  
								 placeholder="配置小程序跳转，需要绑定相关美团小程序"
								 placeholder-class="placeholder-class"
								class="search-ipu-goods "  />
							</view>
							<view class="goto" >
								<radio-group @change="(res)=>{add.data.gotoCurrent=res.detail.value}" class="radio">
									<label class="justify flex" style="flex-direction: row;" v-for="(item, index) in gotorAdioGroup" :key="item.value">
										
										<radio class="justify" :value="item.value" :checked="item.value === add.data.gotoCurrent" />
										
										<view class="justify">{{item.name}}</view>
									</label>
								</radio-group>
							</view>
							
							
							<view class="settingLeftTitle status0 font12">
								<view  selectable="true">
								当在小程序内打开，将跳转第三方小程序（appid不存在则会跳转至第三方网页，但第三方域名必须在小程序中配置）
								</view>
								<view  selectable="true">
								当在浏览器内打开，将跳转第三方H5链接
								</view>
							</view>
							
						</view>
						
						<!-- 展开跳转第三方设置 -->
						<view class="xiala" 
						:class="gotoMt==false ? 'xiala1':'xiala2'"
						@click="gotoMt = !gotoMt"
						>
							{{gotoMt==false ? '展开跳转第三方设置':'收缩'}}
						</view>
						
						
						<!-- 商品介绍 -->
						<view class="add-box">
							<textarea class="textarea" type="text"
							maxlength="-1"
							:adjust-position="true"
							style="height: 300rpx ;"
							v-model="add.data.content" 
							placeholder="这是一个商品的详细内容,一般情况下用于小程序商品详情页面介绍,可用HTML代码进行展示"
							placeholder-class="placeholder" >
							</textarea>
							<view class="goods-info-image">
								<!-- 开始上传商品图片 -->
								<view class="goodsAddBox "  @click="chooseImageInfo">
									<view class="margin">
										<img  src="../../static/img/goodsAdd.png" class="goodsAddImage" @click="chooseImage"></img>
										<text class="tips">上传图片</text>
									</view>
									
									
								</view>
								
								
								<view v-for="(item,index) in goods_info_image" :key="index" class="image-boxs ">
									<image :src="item.reduce" mode="widthFix" class="images" @click="previewImage(index,goods_info_image)"></image>
									
									<view class="deleteImg" 
									@click="$common.noMultipleClicks('goods_info_image_delete',goods_info_image_delete,index)">
										<image  src="/static/img/close.png" class="alter_sure"></image>
									</view>
									
								</view>
								
							</view>
							
						</view>




						<!-- 新增时间 -->
						<view class="add-goods-box " v-if="add.data.time">
							<view class="add-goods flex1 font12">
								更新时间：
								<view class = "font12">
									{{$common.GetFormattedDate(add.data.time*1000,true,true,true)}}
								</view>
							</view>
						</view>

						<!-- 操作按钮 -->
						<view class="add-box bottom-but">
							<view class="but-boxs">
								<view @click="alter_cancel" class="pc-btn cancel">取 消</view>
								
								<view @click="alterSureAdd" class="pc-btn confirm">
									<img src="../../static/img/add.png" class="btn-icon">
									{{add.update_id==0 ?'确 定 新 增':'保 存 修 改'}}
								</view>
								
								<view v-if="add.update_id.length>1"  @click="Save_as" class="pc-btn saveas">
									另存为新增
								</view>
								
							</view>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- end -->
		
		<!-- 商品图片库 -->
		<upload_image ref="uploadImage"></upload_image>
		<!-- end -->
		
		<!-- 商城商品二维码 -->
		<uni-popup ref="GoodsQrCodeShow" type="center" title="商城商品二维码" minHeight="auto" minWidth="auto">
			<view class="box-infos">
				<view class="justify margin gap10">
					<img :src="GoodsQrCode" class=""></img>
					<view selectable="true"  class="qrcodeTitle">使用微信进行扫码进入小程序使用</view>
				</view>
			</view>
		</uni-popup>
		<!-- end -->
		
		<!-- 增加分类 遮罩层 -->
		<uni-popup ref="header_setting" type="center" title="商品分类设置管理">
			<header_lid @onUpdate="HeaderCallbackF" class="h100"></header_lid>
		</uni-popup>
		<!-- end -->
		
		<!-- 用户详情页 -->
		<uni-popup ref="page_admin" type="center" title="新增" >
			<person_admin status="firm_user_list" sendType="gys" class="page-boxs h100"></person_admin>
		</uni-popup>
		<!-- end -->
		<!-- 商品卡密 -->
		<uni-popup v-if="TabcheckedIndex>=0" ref="goods_card" type="center" :title="`${resData.list[TabcheckedIndex].name}卡密管理`" >
			<goods_card  :OnGoodsId="resData.list[TabcheckedIndex].id"></goods_card>
		</uni-popup>
		<!-- end -->
		<goods_disabled ref="goods_disabled" ></goods_disabled>

	</view>
</template>

<script>
	import goods_card from "@/components/goods/card.vue"
	import excel from "@/components/excel.vue"
	import countdown from "@/components/cz-countdown/cz-countdown"
	import header_select from "@/components/header-get/header_select.vue"

	import xinjinheader from "@/components/xinjin-header/xinjin-header.vue"
	import pages from "@/components/admin-components/pages.vue"
	import header_lid from "@/components/admin-components/header_lib.vue"
	import empty from "@/components/admin-components/empty.vue"
	import goods_record from "@/components/goods_record/goods_record.vue"
	import userSelect from "@/components/user/select.vue"
	import select_input from "@/components/select_input/input.vue"
	import goods_disabled from "@/components/goods/disabled.vue"
	import person_admin from "@/components/user/list.vue"
	import upload_image from "@/components/goods/upload_image.vue"
	export default{
		name:'shopping_admin',
		components: {
			pages,xinjinheader,header_lid,empty,header_select,goods_record,countdown,userSelect,select_input,goods_disabled,person_admin,upload_image,excel,goods_card
		},
		beforeCreate(){
			this.$options.components.order_money = require('@/components/admin-components/order_money.vue').default 
		},
		data(){
			return{
				gotorAdioGroup:[
					{
						value: '1',
						name: '不应用设置',
						checked: 'true'
					},
					{
						value: '2',
						name: '点击商品即跳转打开',
						checked: 'false'
					},
					{
						value: '3',
						name: '点击购买按钮跳转打开',
						checked: 'false'
					},
				],
				checkUpdate:{
					Mode:-1,//批量修改的模式
					isSelectAll:false,
					value:''
				},
				moveElementPositionData:false,
				sumData:{
					getSales:{
						value:'',
						status:''
					},
					getMargin:{
						value:'',
						status:''
					},
					getPifa:{
						value:'',
						status:''
					},
					getJinjia:{
						value:'',
						status:''
					},
				},
				showTab:true,
				bjdj_money:false,//编辑等级价格
				bjkc_money:false,//编辑库存
				isSelectAll:false,
				checkbox:{//多选框
					checkbox_status:[],
					select_all:false,
					select:false,
				},
				settingShrink:false,//更多的设置的收缩、展开
				moneyShrink:false,//价格相关的收缩、展开
				kucunShrink:false,//库存的展开与收缩
				headerShrink:false,//分类的展开与收缩
				AccountShrink:false,//用于充值的输入的备注字段名
				gotoMt:false,//跳转第三方设置的可见
				GoodsClickFocus:{
					value:'',//修改后的内容
				},
				selectTypesData:{//品牌弹出选择
					list:[],
				},
				selectBrandData:{//品牌弹出选择
					list:[],
				},
	
				goodsMoveHeader:{//移动目录
					checkbox:{//多选框
						checkbox_status:[],
						select_all:false,
					},
					headerId:'',//分类 id
					headerName:'',//分类 名
					directoryId:'',//目录id
					directoryName:'',//目录 名
				 
				},
				goodsKeywordData:{//批量修改别称的变量
					checkbox:{//多选框
						checkbox_status:[],
						select_all:false,
					},
					keyword:'',//折扣
				},
				pageSearch:{
					value:''
				},
				isScore:0,//
				page:{
					nowPage:1,//当前页数
					pageCount:1,//总页数
					maxCount:0,
					sum:0,
					pageCounts:15,
				},
				resData:{
					list:[]
				},
				TabcheckedIndex:-1,//当前选中的列表项
				add:{
					type:'',
					update_id:'0',//欲修改的ID
					data:{
						gotoCurrent:'1',//跳转第三方的设置
						h5:'',//跳转第三方的H5地址
						app:'',//跳转第三方的app地址
						mp_id:'',//跳转第三方的小程序ID
						mp_path:'',//跳转第三方的小程序路径
						petail_price:0,
						score:0,
						content:'',//
						name:'',
						header:'',
						header_name:'',
						directory:'',
						directory_name:'',
						gonghuo:'',
						gonghuoName:'',
						types:'',
						brand:'',
						position:'',
						descr:'',
						units:'',
						units_sumName:'',
						units_count:1,
						jinhuojia:0,
						pifajia:0,
						allow:0,
						bare_money:0,
						margin:0,
						margin_risk:1,
						level1:0,
						level2:0,
						level3:0,
						level4:0,
						level5:0,
						goodsScore:0,
						isScore:'0',
						account:'',
						tipmsg:'',
						tipmsgType:0
						
					}
				},
				search:{
					focus:false,//是否获得焦点
					word:'',//搜索内容
					goods_id:'',//指定商品
					group_id:'0'
				},
				headerSearch:{
					directory:'',//获取某个目录下的商品
					header:'',
					headerList:[],
				},
				uploadImg:{//上传商品图
					goods_id:'',
					list:[],
					index:-1,
					name:'',
				},
				goods_info_image:[],
				previewImageData:{
					index:-1,
					list:[],
					goods_id:'',
				},
				selectUserVenderData:{
					list :[],
					
				},
				GoodsQrCode:'',//商品小程序码
				gongyingId:'',//供应商ID
				sort:{//排序方式
					value:'',
					index:0
				},
				unclassifieds:false,//是否搜索未分类的商品
				group_on:false,//是否搜索未分组的商品
				slowDay:'',//滞销商品
			}
		},
		 // 此处定义传入的数据
		props: {
			//搜索指定客户的限制商品
			disabled_uid:{
				type: String,
				default: ''
			},
			OnPageSearchGoodsId: {//搜索指定商品
				type: String,
				default: ''
			},
			OnPageSearchGoodsPosition: {//搜索指定货位
				type: String,
				default: ''
			},
			OnPageSearchDirectory: {//搜索指定目录
				type: String,
				default: ''
			},
			OnPageSearchSlowDay: {//搜索滞销商品
				type: String,
				default: ''
			},
			isPop: {//是否弹窗
				type: Boolean,
				default: true
			},
		},
		created() {
			var that = this
			
			this.loadHeader('goods_header_list')
			this.searchBrand()
			this.searchTypes()
			this.GetSelectUserVenderData()
			
			if(this.OnPageSearchGoodsId != undefined && this.OnPageSearchGoodsId.length>0){
				this.search.goods_id = this.OnPageSearchGoodsId
				
			}
			if(this.OnPageSearchGoodsId != undefined && this.OnPageSearchGoodsId.length>0){
				this.search.word = this.OnPageSearchGoodsId
			}
			
			if(this.OnPageSearchGoodsPosition != undefined && this.OnPageSearchGoodsPosition.length>0){
				this.search.word = this.OnPageSearchGoodsPosition
			}
			
			if(this.OnPageSearchDirectory != undefined && this.OnPageSearchDirectory.length>0){
				this.headerSearch.directory = this.OnPageSearchDirectory
			}
			
			if(this.OnPageSearchSlowDay != undefined && this.OnPageSearchSlowDay.length>0){
				this.slowDay = this.OnPageSearchSlowDay
			}
			
			this.loadData(true);
			
		},
		methods:{
			
			/**
			 * 自动分类
			*/
			goodsAiToHeader(){
				var that = this
				uni.showModal({
					title:'请注意！此操作将会把当前列表内的商品进行重新的分类',
					success: function (res) {
						if (res.confirm) {
							var list = that.goodsMoveHeader.checkbox.checkbox_status
							
							that.$common.get_request(
								{
									type: 'goodsAiToHeaderList',
									list: JSON.stringify(list),
								},
								(res)=>{
									that.$common.showModal('提示',res.msg)
									that.searchBut()
								},()=>{},true,"","分类中",0,180000
							);
						}
					}
				})
			},
			
			

			
			addGoods(){
				var that = this
				uni.showModal({
					title:'通过复制其他仓库的商品来进行快速增加商品',
					mask:true,
					editable:true,
					content:'',
					placeholderText:'请输入其他仓库的商品ID',
					success:(res)=>{
						if(res.confirm ){
							if(res.content.length==0){
								that.$common.showModal('提示',"未输入商品ID")
								return
							}
							that.$routeData.goods_copy(res.content,(res)=>{
								that.search.word = res.name
								that.searchReset()
							})
						}
					}
				})
			},
			searchReset(){
				
				this.unclassifieds = false
				this.group_on      = false
				this.slowDay       = ''
				this.$refs.headerRef.reset()
				this.searchBut()
			},
			checkboxuserUpdateCheck(){
				var that = this
				uni.showModal({
					content: '是否确定进行批量操作？',
					success: function (res) {
						if (res.confirm) {
							var list  = []
							
							
							if(that.checkbox.checkbox_status.length<=0){
								var goodsIdArr = []
								 goodsIdArr.push(that.resData.list[that.TabcheckedIndex].id)
							}else{
								var goodsIdArr =  that.checkbox.checkbox_status
							}
								
							for(var i=0;i<goodsIdArr.length;i++){
								list.push({id:goodsIdArr[i]})
							}
							let JsonData = JSON.stringify(list)
							that.choos_all_close()
							that.$common.get_request(
								{
									type:'goodsUpdateCheck',
									value:JsonData,
									id:that.checkUpdate.value,
								},
								(res)=>{
									that.loadData(true)
								},()=>{
									
								
								},true,"","操作中..."
							);
							
							that.checkUpdate.Mode = -1
						}
					}
				});
			},
			moveElementPositionFun(){
				var that = this
				var JsonData = JSON.stringify(this.previewImageData.list)
				
				that.$common.get_request(
					{
						type:'moveElementPosition',
						value:JsonData,
					},
					(res)=>{
						that.moveElementPositionData = false
					},()=>{
						
					},true,"","操作中..."
				);
			},
			//获取总数类
			GetSum(type){
				var that = this
				
				this.sumData.getSales.status  = ''
				this.sumData.getMargin.status = ''
				this.sumData.getJinjia.status  = ''
				this.sumData.getPifa.status  = ''
				
				if(type=='getSales'){
					this.sumData.getSales.status = 1
					
					var body = this.GetBody(true)
					this.$common.get_request(
						body,(res)=>{
							if(res.valueData){
								that.sumData.getSales.value = res.valueData
							}
						}
					);
					
				}else if(type=='getMargin'){
					this.sumData.getMargin.status = 1
					
					var body = this.GetBody(true)
					this.$common.get_request(
						body,(res)=>{
							if(res.valueData){
								that.sumData.getMargin.value = res.valueData
							}
						}
					);
					
				}else if(type=='getJinjia'){
					this.sumData.getJinjia.status = 1
					
					var body = this.GetBody(true)
					this.$common.get_request(
						body,(res)=>{
							if(res.valueData){
								that.sumData.getJinjia.value = res.valueData
							}
						}
					);
					
				}else if(type=='getPifa'){
					this.sumData.getPifa.status = 1
					
					var body = this.GetBody(true)
					this.$common.get_request(
						body,(res)=>{
							if(res.valueData){
								that.sumData.getPifa.value = res.valueData
							}
						}
					);
					
				}else{
					this.sumData.getSales.value = ''
					this.sumData.getMargin.value  = ''
					this.sumData.getPifa.value  = ''
					this.sumData.getJinjia.value  = ''
				}
				
			},
			
			test(){
				
				this.showTab = false
				this.bjdj_money = !this.bjdj_money
				this.$nextTick(() => {
				  // 在这里执行你的更新操作
				  this.showTab = true
				});
			},
			/**
			 * 打开设置独家销售窗口
			*/
			goodsDisabledOpen(){
				if(this.checkbox.checkbox_status.length<=0){
					var goodsIdArr = this.resData.list[this.TabcheckedIndex].id
				}else{
					var goodsIdArr =  this.checkbox.checkbox_status
				}
				this.$refs.goods_disabled.open(goodsIdArr)
			},
			/**
			 * 回调当前选中的表项
			*/
			checkbox_change(e){
				this.isSelectAll = e.detail.value.length>=2 ? true :false
				this.checkbox.checkbox_status = e.detail.value
			},
			/**
			 * 全选中
			*/
			choose_all(){
				//console.log("choose_all")
				this.checkbox.checkbox_status = []
				if(this.checkbox.select_all == false){
					this.checkbox.select_all  = true
					this.checkbox.select      = true
					this.isSelectAll          = true
					for (var i=0;i<this.resData.list.length;i++) {
						this.checkbox.checkbox_status.push(this.resData.list[i].id)
					}

				}else{
					this.choos_all_close()
				}
			},
			/**
			 * 弹出更多操作按钮
			*/
			openActionSheets(item,index,event){
				var that = this
				var itemList = [];
				itemList.push("查询未分类")
				itemList.push("查询未盘点")
				itemList.push("移动分类目录")
				itemList.push("查询积分商品")
				itemList.push("查询未分组商品")
				itemList.push("查询滞销商品")

				uni.showActionSheet({
					itemList:itemList,
					popover:{
						left:event.detail.x,
						top:event.detail.y,
					},
					success: (res) => {
						var tapIndex= res.tapIndex
						if(tapIndex == 0){
							this.unclassifieds = true
							this.group_on      = false //是否搜索未分类的商品
							this.slowDay       = ''
							this.searchBut()
							return
						}
						
						if(tapIndex == 1){
							this.unclassifieds = false
							this.group_on      = false //是否搜索未分类的商品
							this.slowDay       = ''
							this.headerSearch.directory=620
							this.searchBut1()
							return
						}
						
						if(tapIndex == 2){
							this.unclassifieds = false
							this.group_on      = false //是否搜索未分类的商品
							this.slowDay       = ''
							this.$refs.goodsMoveHeader.open()
							return
						}
						
						if(tapIndex == 3){
							this.unclassifieds = false
							this.group_on      = false //是否搜索未分类的商品
							this.slowDay       = ''
							this.searchBut_isScore()
							return
						}
						
						if(tapIndex == 4){
							this.unclassifieds = false
							this.group_on      = true //是否搜索未分类的商品
							this.slowDay       = ''
							this.searchBut()
							return
						}

						if(tapIndex == 5){
							var that = this
							uni.showModal({
								title:'请输入需要检测在指定天数内未销售过的商品',
								mask:true,
								editable:true,
								content:'90',
								placeholderText:'天数',
								success:(res)=>{
									if(res.confirm ){
										if(res.content.length==0){
											that.$common.showModal('提示',"未输入内容")
											return
										}
										that.slowDay     =  res.content //是否搜索滞销
										that.searchBut()
									}
								}
							})
							return
						}
				
					
					}
				})
			},

			/**
			 * 弹出更多操作按钮
			*/
			openActionSheet(item,index,event){
				var that = this
				var itemList = [];
				
				
				itemList.push("删除商品")
				itemList.push("上架商品")
				itemList.push("下架商品")
				
				
				
				uni.showActionSheet({
					itemList:itemList,
					popover:{
						left:event.detail.x,
						top:event.detail.y,
					},
					success: (res) => {
						var tapIndex= res.tapIndex
						if(tapIndex == 0){//修改密码
							that.deleteGoods(that.TabcheckedIndex)
							return
						}
						
						if(tapIndex == 1){
							that.checkboxGroupGoodsGrounding(1)
							return
						}
						
						if(tapIndex == 2){//
							that.checkboxGroupGoodsGrounding(0)
							return
						}
					}
				})
			},
			sendTipmsgTypes(goods_id,mode){
				var that = this
				var list  = []
				list.push({id:goods_id})
				
				
				that.$routeData.sendTipmsgType(list,mode,()=>{
					that.add.data.tipmsgType = mode==1?0:1;
				})
			},
			/**
			 * 弹出设置或 取消备注必填项
			*/
			sendTipmsgType(event){
				var that = this
				var itemList = [];
				itemList.push("取消选中的商品下单必填备注项")
				itemList.push("设置选中的商品下单必填备注项")
			
				uni.showActionSheet({
					itemList:itemList,
					popover:{
						left:event.detail.x,
						top:event.detail.y,
					},
					success: (res) => {
					
						var mode = res.tapIndex
						
						uni.showModal({
							content: '是否确定进行批量操作？',
							success: function (res) {
								if (res.confirm) {
									var list  = []
									
									if(that.checkbox.checkbox_status.length<=0){
										 list.push(that.resData.list[that.TabcheckedIndex].id)
									}else{
										list =  that.checkbox.checkbox_status
									}
									
									that.choos_all_close()
									that.$routeData.sendTipmsgType(list,mode,()=>{
										that.loadData(true)
									})
									
								}
							}
						});
						
					}
				})
			},
			/**
			 * 弹出更多操作按钮
			*/
			openActionSheetMoney(item,index,event){
				var that = this
				var itemList = [];
				itemList.push("批发价格")
				itemList.push("零售价格")
				itemList.push(`${this.$routeData.GetLevelItem('1')['text']}价格`)
				itemList.push(`${this.$routeData.GetLevelItem('2')['text']}价格`)
				itemList.push(`${this.$routeData.GetLevelItem('3')['text']}价格`)
				itemList.push(`${this.$routeData.GetLevelItem('4')['text']}价格`)
				itemList.push(`${this.$routeData.GetLevelItem('5')['text']}价格`)
				itemList.push("赠送积分")
			
				uni.showActionSheet({
					itemList:itemList,
					popover:{
						left:event.detail.x,
						top:event.detail.y,
					},
					success: (res) => {
						var selectIndex = res.tapIndex
						if(selectIndex ==7){
							var title = '请输入让出的利率进行批量修改赠送的积分\r\n\r\n计算公式：\r\n赠送的积分 = (商品批发价-商品进货价) × (输入的利率 ÷ 100)\r\n\r\n最后的实际积分若有小数则默认会进行往下取整数';
						}
						else{
							var title = '请输入抽取的毛利率进行批量修改价格\r\n\r\n计算公式：\r\n最终售价 = 商品成本 ÷ (1 - (输入的利率 ÷ 100))';
						}
							uni.showModal({
							title:title,
							mask:true,
							editable:true,
							placeholderText:'请输入100以内的利率',
							success:(res)=>{
								if(res.confirm ){
									if(res.content.length==0){
										that.$common.showModal('提示',"未输入内容")
										return
									}
									var profitRatePercent = res.content;
									if(profitRatePercent<0){
										that.$common.showModal('提示',"成本不能为小于0%")
										return
									}
									
									
									if(that.checkbox.checkbox_status.length<=0){
										var goodsIdArr = [];
										
										goodsIdArr.push(that.resData.list[that.TabcheckedIndex].id)
									}else{
										var goodsIdArr =  that.checkbox.checkbox_status
									}
									
									if(goodsIdArr.length<=0){
										return
									}
									// that.$common.showModal("请勿关闭或刷新当前页面！")
									that.SheetMoney(selectIndex,goodsIdArr,profitRatePercent)
									
								}
							}
						})
						
					}
				})
			},
			SheetMoney(type,goodsIdArr,value){
				var that = this
				if(goodsIdArr.length<=0){
					that.loadData(false)
					return
				}
				var goods_id = goodsIdArr[0];
				var tmp_goodsIdArr = JSON.parse(JSON.stringify(goodsIdArr))
				tmp_goodsIdArr.splice(0,1)
				
				// 提取此商品价格
				var cost = that.GetGoodsJinhuojia(goods_id)
				
				if(cost != false){
					if(type != 7){
						// 计算得出最终售价
						var sellingPrice = that.calculateSellingPrice(cost.jinhuojia,parseInt(value));
					}else{
						var sellingPrice = (cost.pifajia - cost.jinhuojia) * (value / 100)
					}
					
					if(type == 0){
						that.$routeData.updatePifajia(goods_id,sellingPrice,(res)=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
					else if(type == 1){
						that.$routeData.updatePetailPrice(goods_id,sellingPrice,(res)=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
					else if(type == 2){
						that.$routeData.updateLevelMoney(goods_id,sellingPrice,1,(res)=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
					else if(type == 3){
						that.$routeData.updateLevelMoney(goods_id,sellingPrice,2,(res)=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
					else if(type == 4){
						that.$routeData.updateLevelMoney(goods_id,sellingPrice,3,(res)=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
					else if(type == 5){
						that.$routeData.updateLevelMoney(goods_id,sellingPrice,4,(res)=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
					else if(type == 6){
						that.$routeData.updateLevelMoney(goods_id,sellingPrice,5,(res)=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
					else if(type == 7){
						console.log('sellingPrice',sellingPrice)
						that.$routeData.updateScore(goods_id,parseInt(sellingPrice),()=>{
							that.SheetMoney(type,tmp_goodsIdArr,value);
						})
					}
				}
			},
			calculateSellingPrice(cost, profitRatePercent) {
				// 输入验证
				if (typeof cost !== 'number' || typeof profitRatePercent !== 'number') {
					throw new Error("成本和利润率必须是数字",cost,profitRatePercent);
				}
				
				if (isNaN(cost) || isNaN(profitRatePercent)) {
					throw new Error("成本和利润率不能是NaN");
				}
				
				// 处理成本小于等于0的情况
				if (cost <= 0) {
					// 当成本为0或负数时，直接将利润率百分比转换为金额
					const sellingPrice = Math.max(0, profitRatePercent / 100);
					return sellingPrice.toFixed(2);
				}
				
				// 处理利润率大于等于100%的情况
				if (profitRatePercent >= 100) {
					// 使用加成率公式：售价 = 成本 × (1 + 利润率/100)
					const sellingPrice = cost * (1 + profitRatePercent / 100);
					return Math.max(0, sellingPrice).toFixed(2); // 确保售价不为负
				}
				
				// 处理利润率小于0%的情况
				if (profitRatePercent < 0) {
					// 负利润率意味着折扣，售价低于成本
					const sellingPrice = cost * (1 + profitRatePercent / 100);
					return Math.max(0, sellingPrice).toFixed(2); // 确保售价不为负
				}
				
				// 正常情况：使用基于售价的利润率公式
				const profitRate = profitRatePercent / 100;
				const sellingPrice = cost / (1 - profitRate);
				
				// 处理可能的计算错误（如除数为0）
				if (!isFinite(sellingPrice)) {
					return "计算错误：无效的利润率";
				}
				
				return Math.max(0, sellingPrice).toFixed(2); // 确保售价不为负

			},
			GetGoodsJinhuojia(goodsId){
				for(var i=0;i<this.resData.list.length;i++){
					
					if(goodsId == this.resData.list[i].id){
						return this.resData.list[i]
					}
				}
				return false
			},
			// 取消全选中
			choos_all_close(){
				this.checkbox.select_all = false
				this.checkbox.checkbox_status = []
				this.checkbox.select = false
				this.isSelectAll = false
			},
			checkboxGroupGoodsGrounding(mode){
				var that = this
				uni.showModal({
					content: '是否确定进行批量操作？',
					success: function (res) {
						if (res.confirm) {
							var list  = []
							
							if(that.checkbox.checkbox_status.length<=0){
								 list.push(that.resData.list[that.TabcheckedIndex].id)
							}else{
								list =  that.checkbox.checkbox_status
							}
							
							let JsonData = JSON.stringify(list)
							that.choos_all_close()
							that.$common.get_request(
								{type:'mp_grounding',value:JsonData,mode:mode},
								(res)=>{
									that.loadData(true)
								},()=>{
									
								
								},true,"","操作中..."
							);
						}
					}
				});
			},
			
			inputAllow(res){
				var tmp = res.detail.value
				if(this.add.data.allow.length<=0){
					this.add.data.allow = tmp
				}
			},
			//发起搜索
			searchBut_isScore(){
				this.headerSearch.directory = ''
				this.headerSearch.header = ''
				this.sort.value = ""
				this.sort.index = 0
				this.isScore    = 1
				this.loadData(true)
			},
			//发起搜索
			searchBut(){
				this.headerSearch.directory = ''
				this.headerSearch.header = ''
				this.sort.value = ""
				this.sort.index = 0
				this.isScore = 0
				this.loadData(true)
			},
			//发起搜索
			searchBut1(){
				this.sort.value = ""
				this.sort.index = 0
				this.loadData(true)
			},
			/**
			 * 选中厂家后的回调
			*/
			onclickSelectUser(item){
				//console.log("item",item)
				if(item==null){
					this.gongyingId = ''
					//console.log("清除了厂家ID")
					return
				}
				this.gongyingId = item.id
			},
			/**
			 * 搜索适配车型
			*/
			searchTypes(){
				var that = this
				that.$common.get_request(
					{
						type:'searchTypes',
					},
					(res)=>{
						that.selectTypesData.list = res.list
					}
				);
			},
		
			/**
			 * 搜索品牌
			*/
			searchBrand(){
				var that = this

				that.$common.get_request(
					{
						type:'searchBrand',
					},
					(res)=>{
						that.selectBrandData.list = res.list
					}
				);
			},
		
			
			
			/**
			 * 移动目录-选中
			*/
			GoodsMoveHeaderSelectListIndex(res){
				this.goodsMoveHeader.directoryId = res.directory.id
				this.goodsMoveHeader.directoryName = res.directory.name
				
				this.goodsMoveHeader.headerId = res.header.id
				this.goodsMoveHeader.headerName = res.header.name
			},
			/**
			 * 移动目录-选中
			*/
			GoodsMoveHeaderChooseAll(){
				this.goodsMoveHeader.checkbox.checkbox_status = []
				if(this.goodsMoveHeader.checkbox.select_all == false){
					this.goodsMoveHeader.checkbox.select_all = true
					this.goodsMoveHeader.checkbox.select     = true
					var tmpList = this.resData.list;
					for (var i=0;i<tmpList.length;i++) {
						this.goodsMoveHeader.checkbox.checkbox_status.push(tmpList[i].id)
					}
					
				}else{
					this.GoodsMoveHeaderDataChoosAllClose()
				}
			},
			/**
			 * 移动目录-单选按钮的操作
			*/
			GoodsMoveHeaderCheckboxChange(e){
				if(e.detail.value.length>0){
					this.goodsMoveHeader.checkbox.checkbox_status.push(e.detail.value[0])
				}
			},
			/**
			 * 移动目录-请求操作
			*/
			GoodsMoveHeaderUpdate(){
				var that = this
				if(that.goodsMoveHeader.checkbox.checkbox_status.length<=0){
					that.$common.showModal('失败','请选择后再试')
					return
				}
				var list = that.goodsMoveHeader.checkbox.checkbox_status
				var lists = {}
				var data  = []
				for(var i=0;i<list.length;i++){
					lists.id        = list[i]
					lists.directory = that.goodsMoveHeader.directoryId
					lists.header    = that.goodsMoveHeader.headerId
					
					data.push(lists)
				}
				
				that.$common.get_request(
					{
						type:'updateGoodsDirectory',
						json_data:JSON.stringify(data),
					},
					(res)=>{
						// 清除全选按钮
						that.goodsMoveHeader.checkbox.select_all = false
						that.goodsMoveHeader.checkbox.checkbox_status = []
						
						that.$common.toast(res.msg)
						that.GoodsMoveHeaderDataChoosAllClose()
					}
				);
			},
			// 移动目录-取消全选中
			GoodsMoveHeaderDataChoosAllClose(){
				this.goodsMoveHeader.checkbox.select = false
				this.goodsMoveHeader.checkbox.select_all = false
				this.goodsMoveHeader.checkbox.checkbox_status = []
			},
			/**
			 * 批量修改别称-网络请求
			*/
			GoodsKeywordDataUpdate(){
				var that = this
				
				if(that.goodsKeywordData.checkbox.checkbox_status.length<=0){
					that.$common.showModal('失败','请选择后再试')
					return
				}
				that.$common.get_request(
					{
						type:'updateGoodsKeyword',
						keyword:that.goodsKeywordData.keyword,
						json_data:JSON.stringify(that.goodsKeywordData.checkbox.checkbox_status),
					},
					(res)=>{
						that.$common.toast(res.msg)
						that.GoodsKeywordDataChoosAllClose()
					}
				);
			},

			/**
			 * 批量修改别称-选中
			*/
			GoodsKeywordDataChooseAll(){
				this.goodsKeywordData.checkbox.checkbox_status = []
				if(this.goodsKeywordData.checkbox.select_all == false){
					this.goodsKeywordData.checkbox.select_all = true
					this.goodsKeywordData.checkbox.select     = true
					var tmpList = this.resData.list;
					for (var i=0;i<tmpList.length;i++) {
						this.goodsKeywordData.checkbox.checkbox_status.push(tmpList[i].id)
					}
					
				}else{
					this.GoodsKeywordDataChoosAllClose()
				}
			},

			/**
			 * 批量修改别称-全选按钮的操作
			*/
			GoodsKeywordDataCheckboxChange(e){
				this.goodsKeywordData.checkbox.checkbox_status = e.detail.value
			},

			// 批量修改别称-取消全选中
			GoodsKeywordDataChoosAllClose(){
				this.goodsKeywordData.checkbox.select = false
				this.goodsKeywordData.checkbox.select_all = false
				this.goodsKeywordData.checkbox.checkbox_status = []
			},

			checkGoodsProfit(id){
				var that   = this
				var tmpArr = that.resData.list
				for(var i=0;i<that.resData.list.length;i++){
					if(that.resData.list[i].id==id){
						return i;
					}
				}
				return -1;
			},

			/**
			 * 读取厂家
			 * type : goods_list|goods_search
			 * 
			*/
			GetSelectUserVenderData(isUpdatePage=true){
				var that = this
				
				that.$common.get_request(
					{
						type:'firm_user_list',
						user_type:'gys',//根据类型获取不同的账号类型  kh、yg、gys
					},
					
					(res)=>{
						that.selectUserVenderData.list = res.list
					}
				);
			},
			
		
			/**
			 * 删除
			 * 
			*/
		   deleteGoods(index){
				var that = this
				uni.showModal({
					content: '是否确定进行删除操作？此操作不可逆。删除后有关信息无法恢复！',
					success: function (res) {
						if (res.confirm) {
							var list  = []
							
							if(that.checkbox.checkbox_status.length<=0){
								 list.push(that.resData.list[that.TabcheckedIndex].id)
							}else{
								list =  that.checkbox.checkbox_status
							}
							
							
							let JsonData = JSON.stringify(list)
							that.choos_all_close()
							that.$common.get_request(
								{type:'delete_goods',value:JsonData},
								(res)=>{
									that.loadData()
								},()=>{
									
								},true,"","操作中..."
							);
						}
					}
				});
		   },
			goodsRecordClose(){
				this.$refs.goods_record.close()
			},
			/**
			 * 上架商城
			 * 
			*/
			fun_mp_grounding(index,mode){
				var that = this
				var arr  = []
				arr.push(that.resData.list[index].id)

				that.$common.get_request(
					{type:'mp_grounding',value:JSON.stringify(arr),mode:mode},
					(res)=>{
						that.resData.list[index].mp_grounding = mode
					},
					(res)=>{},
					
				);
			},
			/**
			 * 创建商品二维码
			 * 
			*/
			createQrcode(id){
				var that  = this
				var imgArr= []
				// var data  = {}
				
				// data.type = 'goods_info'
				// data.goods_id = id 
				let url   = this.$common.baseUrl.host + this.$common.baseUrl.qrcodeUrl +'?type=test&id='+id
				imgArr.push(url)
				uni.previewImage({
					urls:imgArr,
					fail:(e)=>{
					}
				})
			},
			/**
			 * 创建商城商品二维码
			 * 
			*/
			getwxacodeunlimit(item){
				var that=this
				if(item.mp_grounding==0){
					that.$common.toast("商品未上架商城无法生成直达二维码")
					return
				}
				that.$common.get_request(
					{type:'getwxacodeunlimit',goods_id:item.id,path:'goods'},
					(res)=>{
						that.GoodsQrCode = 'data:image/png;base64,' +res.base64
						that.$refs.GoodsQrCodeShow.open()
					},
					(res)=>{},
				);
			},
			/**
			 * 选择分类的回调
			 * 
			*/
			call_directory(res){
				//let item = this.headerData.list[res.header.index].list[res.directory.index]
				//this.headerData.seleList.push(item)
			
				this.add.data.header = res.header.id
				this.add.data.header_name = res.header.name
				
				this.add.data.directory = res.directory.id
				this.add.data.directory_name = res.directory.name
				
			},	
			fun_name_create(){
				this.add.data.name = this.add.data.types+this.add.data.directory_name+'('+this.add.data.brand+')'
			},
			/**
			 * 商品图片-设为默认
			 * 
			*/
			imgConnive(index){
				var that = this
				//检测是否为本地照片还没有上传的
				if(that.previewImageData.list[index].type!=undefined && that.previewImageData.list[index].type == "tmp"){
					return
				}
				if(that.previewImageData.list[index].connive==0){
					return;
				}
				var id = that.previewImageData.list[index].id
				that.$common.get_request(
					{type:'goodsImgConnive',id:id},
					(res)=>{
						//初始化默认显示
						that.previewImageData.list.forEach((item,i)=>{
							if(i==index){
								item.connive=0
							}else{
								item.connive=1
							}
						})
						
						that.$set(that.previewImageData.list,index,that.previewImageData.list[index])
					}
				);
			},
			/**
			 * 商品图片-删除
			 * 
			*/
			fun_img_de(index){
				var that = this
				//检测是否为本地照片还没有上传的
				if(that.previewImageData.list[index].type!=undefined && that.previewImageData.list[index].type == "tmp"){
					//再删除前取出待上传的文件路径
					var filePath = that.previewImageData.list[index].source
					//删除
					that.previewImageData.list.splice(index,1)
					//删除待上传列表中的数据
					for(var i=0;i<that.uploadImg.list.length;i++){
						if(that.uploadImg.list[i]==filePath){
							that.uploadImg.list.splice(i,1)
							return
						}
					}
					
					return
				}
				var id = that.previewImageData.list[index].id
				that.$common.get_request(
					{type:'goods_img_de',id:id},
					(res)=>{
						that.previewImageData.list.splice(index,1)
					}
				);
			},
			
			/**
			 * 商品图片-打开管理
			 * 
			*/
			imageOpen(preview=false,index){
				this.previewImageData.list = this.resData.list[index].img
				this.previewImageData.goods_id = this.resData.list[index].id
				this.uploadImg.goods_id = this.resData.list[index].id
				this.uploadImg.index = index
				this.uploadImg.name  = this.resData.list[index].name
				if(preview==false){
					this.uploadImg.list = []
					this.$refs.image.open()

				}else{
					this.previewImage(-1,this.previewImageData.list)
				}
			},
			/**
			 * 商品图片-复用其他商品的图片-打开弹窗
			*/
			reuseGoodsImage(){
				var that = this
				uni.showModal({
					title:'复制目标商品图片下方的图片ID粘贴此处提交即可；每次/张',
					mask:true,
					editable:true,
					placeholderText:'请输入图片ID',
					success:(res)=>{
						if(res.confirm ){
							if(res.content.length==0){
								that.$common.showModal('提示',"未输入图片ID")
								return
							}
							var image_id = res.content;
							var goods_id = that.uploadImg.goods_id
							//上传
							that.$common.get_request(
								{type:'reuseGoodsImage',goods_id:goods_id,image_id:image_id},
								(res)=>{
									that.getGoodsImg(goods_id)
								}
							);
						}
					}
				})
			},
			/**
			 * 网络链接导入
			*/
			readImageFile(){
				var that = this
				uni.showModal({
					title:'输入网络连接Url！可多行，一行一个\n点击下方搜索',
					mask:true,
					editable:true,
					placeholderText:'请输入连接Url',
					success:(res)=>{
						if(res.confirm ){
							if(res.content.length==0){
								that.$common.showModal('提示',"未输入内容")
								return
							}
							var Url = res.content.trim();
							var lines = Url.split("\n");  
							lines.forEach((item)=>{
								that.previewImageData.list.push({
									source:item,
									reduce:item,
									type:"tmp",
									name:'',
								})
								that.uploadImg.list.push(item)
								that.fun_uploadImg()
							})
						}
					}
				})
			},
	
		
			/**
			 * 商品图片-复用商品的全部图片-打开弹窗
			*/
			reuseGoodsImageAll(){
				var that = this
				uni.showModal({
					title:'复制目标商品的商品ID粘贴此处提交可获得目标的全部图片，商品ID位于列表序号中',
					mask:true,
					editable:true,
					placeholderText:'请输入商品ID',
					success:(res)=>{
						if(res.confirm ){
							if(res.content.length==0){
								that.$common.showModal('提示',"未输入其他商品的ID")
								return
							}
							var goods_ids = res.content;
							var goods_id = that.uploadImg.goods_id
							//上传
							that.$common.get_request(
								{type:'reuseGoodsImageAll',goods_id:goods_id,goods_ids:goods_ids},
								(res)=>{
									that.getGoodsImg(goods_id)
								}
							);
						}
					}
				})
			},
			/**
			 * 商品图片-打开管理
			*/
			PageTurningOpen(type){
				var index = this.uploadImg.index
				if(type=='add'){
					index++;
					if(index>=this.resData.list.length){
						this.$common.showModal('提示',"已到达当前页的最后一个商品，请翻页以继续...")
						return
					}
					
				}else{
					index--;
					if(index<0){
						this.$common.showModal('提示',"已到达当前页的第一个商品，请翻页以继续...")
						return
					}
				}
				this.imageOpen(false,index)
				this.TabcheckedIndex = index
				this.$common.toast("成功")
			},
			/**
			 * 商品-预览
			*/
			previewImage(index=-1,imageList){
				var that   = this
				var imgArr = []
				var tmpList= imageList ;//that.previewImageData.list
				var tmpListCount  = tmpList.length;
				if(index>=0){
					if(index>=tmpListCount){
						return
					}
					
					//加入当前选中的图片为第一张
					imgArr.push(tmpList[index].source)
					
					for (var i=0;i<tmpListCount;i++) {
						if(i!=index){//不是刚刚已经加入那张图片的话就往下执行
							imgArr.push(tmpList[i].source)
						}
					}
					
					
				}else{
					for (var i=0;i<tmpListCount;i++) {
						imgArr.push(tmpList[i].source)
					}
				}
				uni.previewImage({
					urls:imgArr,
					fail:(e)=>{
					}
				})
			},
			/**
			 * 商品上传-选择图片
			*/
			chooseImage(){
				var that = this
				var filePath = ''
				uni.chooseImage({
					count:9,
					sizeType: ['compressed'], //original 原图，compressed 压缩图，
					success:(e)=>{
						e.tempFilePaths.forEach((item,index)=>{
							filePath = item;
							that.previewImageData.list.push({
								source:filePath,
								reduce:filePath,
								type:"tmp",
							})
							that.uploadImg.list.push(item)
						})
					},
					fail:(res)=>{
						if(res.errMsg){
							uni.showModal({
									title:'错误',
									content:res.errMsg,
									showCancel:false
							});
						}
					}
				})
			},	
			
			/**
			 * 商品上传-选择详情图片
			*/
			chooseImageInfo(){
				var that = this
				var filePath = ''
				uni.chooseImage({
					count:9,
					sizeType: ['compressed'], //original 原图，compressed 压缩图，
					success:(e)=>{
						e.tempFilePaths.forEach((item,index)=>{
							filePath = item;
							
							that.$common.uploadFile(
								filePath,
								{type:'goods_info_image_upload',goods_id:that.add.update_id},
								(res)=>{
									that.goods_info_image.push(res.data[res.data.length-1])
									console.log(that.goods_info_image,res)
								},
							)
							
						})
					},
					fail:(res)=>{
						if(res.errMsg){
							uni.showModal({
									title:'错误',
									content:res.errMsg,
									showCancel:false
							});
						}
					}
				})
			},
			
			/**
			 * 商品图片-删除详情图片
			 * 
			*/
			goods_info_image_delete(index){
				var that = this
			
				var id = that.goods_info_image[index].id
				that.$common.get_request(
					{type:'goods_info_image_delete',id:id},
					(res)=>{
						that.goods_info_image.splice(index,1)
					}
				);
			},
			
			/**
			 * 开始上传图片
			 * 
			*/
			fun_uploadImg(){
				var that = this
				if(that.uploadImg.list.length>0){
					
					var index = that.uploadImg.list.length-1;
					var ImageUrl = that.uploadImg.list[index];
					//console.log(ImageUrl.substring(0, 4))
					//区分互联网图片还是本地图片
					if(ImageUrl.length>3 && ImageUrl.substring(0, 4) === 'http'){
						
						that.$common.get_request(
							{type:'goods_upload',goods_id:that.uploadImg.goods_id,internetUrl:ImageUrl},
							(res)=>{
								that.uploadImg.list.splice(index,1)
								that.fun_uploadImg()
							}
						);
					}else{
					
						that.$common.uploadFile(
							ImageUrl,
							{type:'goods_upload',goods_id:that.uploadImg.goods_id},
							(res)=>{
								that.uploadImg.list.splice(index,1)
								that.fun_uploadImg()
							},
						)
					}
				}else{
					//上传完毕后刷列表
					that.getGoodsImg(that.uploadImg.goods_id)
				}
			},
			/**
			 * 更新图片数据
			*/
			getGoodsImg(goods_id){
				var that = this
				that.$common.get_request(
					{type:'goods_img',id:goods_id},
					(res)=>{
						that.resData.list[that.uploadImg.index].img = res.data
						that.previewImageData.list = res.data
					}
				);
			},
			/**
			 * 分页器回调
			*/
			updatePage(pageName,pageCount){
				console.log(pageName,pageCount)
				var that = this
				that.page.nowPage = pageName
				that.page.pageCounts = pageCount
				that.loadData(false);
			},
			/**
			 * 回调的刷新、搜索
			*/
			HeaderCallbackF(e){
				this.loadHeader('goods_header_search',e)
			},
			/**
			 * 本地搜索，目录
			*/
			headerSearchDirectory(e){
			},
			/**
			 * 读取分类
			 * type : goods_list|goods_search
			 * 
			*/
			loadHeader(type='goods_header_list',searchContent=''){
				var that = this
				that.$common.get_request(
					{type:type,search:searchContent},
					
					(res)=>{
						that.headerSearch.headerList = res.list
					}
				);
			},
			/**
			 * 分类插件回调返回
			*/
			formsubmit(e){
				this.headerSearch.directory = e
				this.sort.value = ''//清除排序方式
				this.search.word = ''//搜索内容
				this.search.group_id = ''
				this.page.nowPage = 1
				this.unclassifieds = false
				this.loadData(true)
			},
			/**
			 * 分类插件回调返回
			*/
			onHeader(e){
				this.headerSearch.directory = ''
				this.headerSearch.header = e
				this.sort.value = ''//清除排序方式
				this.search.word = ''//搜索内容
				this.search.group_id = ''
				this.page.nowPage = 1
				this.unclassifieds = false
				this.loadData(true)
			},
			GetBody(isUpdatePage){
				this.page.nowPage = isUpdatePage==true ? 1:this.page.nowPage;
				return {
						type:'goods_list',
						search:this.search.word,//搜索内容
						pages:this.page.nowPage,//当前位于页数
						page_count:this.page.pageCounts,//当前请求页的数量
						directory: this.headerSearch.directory,//获取某个目录下的商品
						header:this.headerSearch.header,
						sort:this.sort.value,
						gongyingId:this.gongyingId,//指定厂家
						unclassified:this.unclassifieds,//是否搜索未分类的商品
						goods_id: this.search.word.length==0 ? this.search.goods_id:'',//指定用户搜索
						position:this.OnPageSearchGoodsPosition,
						disabled_uid:this.disabled_uid,
						isScore:this.isScore,
						getSales:this.sumData.getSales.status,
						getMargin:this.sumData.getMargin.status,
						getJinjia:this.sumData.getJinjia.status,
						getPifa:this.sumData.getPifa.status,
						group_id:this.search.group_id,
						group_on:this.group_on,//是否搜索未分组的商品
						slowDay:this.slowDay,//搜索滞销商品
						
					};
			},
			/**
			 * 读取商品
			 * type : goods_list|goods_search
			 * isUpdatePage : 如果是分页器回调的就不出时候页码，如果是点击获取数据的就初始化页码为1
			 * 
			*/
			loadData(isUpdatePage=true,goods_id=null,ReqExport=0){
				var that = this
				this.choos_all_close()
				this.GoodsKeywordDataChoosAllClose()
				this.GetSum('')
				if(goods_id==null){
					//常规的筛选项
					var body = this.GetBody(isUpdatePage)
				}else{
					//新增、修改后。只获取某一个商品的
					var body = {
						type:'goods_list',
						goods_id:goods_id
					};
				}
				that.$common.get_request(
					body,
					(res)=>{
						res.list.forEach((item, index) => {
							item.pifajia = item.pifajia
							item.jinhuojia = item.jinhuojia
						});
						that.resData = res
						
						
						
						that.page.sum  = res.sum
						if(isUpdatePage == true){
							that.page.nowPage  = 1
						}
						

						 //搜索框获得焦点
						 that.search.focus = true
						 //取消全选
						 that.GoodsKeywordDataChoosAllClose()
						 that.GoodsMoveHeaderDataChoosAllClose()
						 that.TabcheckedIndex = res.list.length > 0 ? 0 : -1//初始化列表选中项
					}
				);
			},
			/**
			 * 关闭增加的弹窗
			*/
			alter_cancel(){
				this.$refs.popup.close()
			},
			/**
			 * 另存为新增
			*/
			Save_as(){
				this.add.type="goods_add"
				this.add.update_id=0//改变这个就可以作为新增了
				this.alterSureAdd()
			},
			/**
			 * 发送增加、修改弹窗
			*/
			alterSureAdd(){
					var that = this
					function isNumber(value) {         //验证是否为数字
					    var patrn = /^(-)?\d+(\.\d+)?$/;
					    if (patrn.exec(value) == null || value == "") {
					        return false
					    } else {
					        return true
					    }
					}
				
					if(that.add.data.pifajia < that.add.data.allow){
						uni.showToast({
							title:"商品最低销售价格需大于批发价格，否则出错！请修正后再试。",
							icon:'none'
						})
						return false
					}
					if(that.add.data.position.length>0 && that.$common.containsLetter(that.add.data.position)==false){
						uni.showToast({
							title:"商品货位号必须含有字母，否则出错！请修正后再试。",
							icon:'none'
						})
						return false
					}
					
					uni.showModal({
						content: '是否确定增加或修改？',
						success: function (res) {
							if (res.confirm) {
								let body = {}
								body = JSON.parse( JSON.stringify(that.add.data) ) //避免变量赋值后双向绑定
								
								body.descr = encodeURIComponent(body.descr)
								body.name = encodeURIComponent(body.name)
								
								body.update_id = that.add.update_id
								body.type = that.add.type
								//console.log(body)
								//return
								that.$common.get_request(
									body,
									(res)=>{
										that.alter_cancel();//关闭弹窗
										that.sort.value=''
										that.headerSearch.directory =''
										that.headerSearch.header =''
										//that.loadData(true)
										that.loadData(true,res.goods_id)
										
										if(res.IsUpdateHeader != undefined && res.IsUpdateHeader==true){//刷新分类
											that.loadHeader()
										}
									}
								);
							}
						}
					});
			},
			/**
			 * 打开商品记录
			 * 
			*/
			OpenGoodsRecord(item){
				
				this.pageSearch.value =  item.id
				this.$refs.goods_record.open()
			},
			/**
			 * 编辑某条商品
			 * 
			*/
			Fun_alter(index,number,goods_id){
				var that = this
			
				if(goods_id<=0){return}
				that.add.type='goods_update'

				that.$common.get_request(
					{type:'goodsidGetName',goods_id:goods_id},
					(res)=>{
						res.data.pifajia = res.data.pifajia
						res.data.linshou = res.data.linshou
						res.data.jinhuojia = res.data.jinhuojia
						that.resData.list[index] = res.data
						that.resData.list[index].number = number
						
						that.goods_info_image = res.data.goods_info_image
						this.$set(that.resData.list,index,that.resData.list[index])
						var tmp = that.resData.list[index]
						that.add.data      =  JSON.parse( JSON.stringify(tmp) ) //避免变量赋值后双向绑定
						// console.log('tmp.gotoCurrent',tmp.gotoCurrent,tmp)
						that.add.data.gotoCurrent = tmp.gotoCurrent == '' ? '1':tmp.gotoCurrent 
						that.$refs.popup.open()
						
						that.add.update_id = goods_id
					}
				);
				
			},
			/**
			 * 打开增加商品窗口
			 * 
			*/
			addShow(){
				this.add.update_id = 0
				this.add.type='goods_add'
				this.$refs.popup.open()
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	.goto{
		float: none;
		width: 100%;
		display: flex;
		margin: auto 0px;
		height: 32px;
		border: solid 1px #d5d5d5;
		padding: 10px 5px;
	}
	.goto .radio{
		display: flex;
		white-space: normal;
		width: 100%;
		flex-direction: row;
		display: inline-flex;
		gap: 20px;
		margin: auto;
		flex-direction: row;
		justify-content: center;
	}
.input-measure {
    visibility: hidden;
    height: 0px;
    overflow: hidden;
    white-space: pre;
    font-size: 16px;
    font-family: inherit;
    line-height: 0px;
    height: 0px;
    display: flex;
}
	.left-right{
		width: 100%;
		position: absolute;
		display: flex;
	}
	.align-items{
		    flex-direction: row;
		    align-items: center;
	}
	.sousouk{
		padding: 0px 0px;
		display: flex;
		justify-content: center;
		border-radius: 8px;
		height: 32px;
		justify-content: center;
		align-items: center;
		cursor: pointer;
		margin: auto 0px ;
		float: left;
	}
/* PC端优化样式 */
.goods-edit-pc {
    padding: 24px;
    background: #f5f7fa;
    min-height: 100vh;
}

.edit-main {
    max-width: 1200px;
    margin: 0 auto;
}

.add-box-goods {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    width: calc(100% - 40px);
    display:grid;
    flex-wrap: wrap;
    gap: 20px;
	grid-template-columns: repeat(2, 1fr);
}
.add-box {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    width: calc(100% - 40px);
    display:flex;
    flex-wrap: wrap;
    gap: 20px;
}
.riskTitle {
    color: #333;
    flex-shrink: 0;
	font-size: 14px;
}

.pc-input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    transition: border-color 0.3s;
    
    &-sm {
        width: 180px;
    }
    
    &-lg {
        width: 400px;
    }
    
    &-money {
        width: 200px;
    }
    
    &:focus {
        border-color: #409eff;
        outline: none;
    }
}

.pc-select {
    flex: 1;
    :deep .uni-select__input-box {
        height: 36px;
    }
}

.pc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: center;
}

.but-box {
    margin-top: 24px;
}

.but-boxs {
	display: flex;
	gap: 15px;
	justify-content: center;
}
.pc-btn {
    padding: 8px 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    
    &.confirm {
        background: #409eff;
        color: #fff;
        &:hover {
            background: #66b1ff;
        }
    }
    
    &.cancel {
        border: 1px solid #dcdfe6;
        &:hover {
            border-color: #c0c4cc;
        }
    }
    
    &.saveas {
        color: #409eff;
		border:solid 1px;
        &:hover {
            background: #ecf5ff;
        }
    }
}

.btn-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
}

.form-tip {
    color: #909399;
    font-size: 12px;
    margin-left: 10px;
	text-align: left;
	float: none;
	flex: 1;
	justify-content: center;
	display: flex;
	flex-direction: column;
}

.name-create {
    color: #67c23a;
    padding: 6px 12px;
    background: #f0f9eb;
    border-radius: 4px;
    cursor: pointer;
}
.bottom-but{
	position: sticky;
	bottom: 0px;
	margin-bottom: 0px;
	padding: 0px;
	left: 0px;
	z-index: 2;
	gap: inherit;
	flex-wrap: initial;
	width: 100%;
}
.textarea{
	height: 150px;
	width: 100%;
	border: solid 1px #d5d5d5;
	text-align: left;
	padding: 5px;
}
.xiala{
	height: 30px;
	width: 200px;
	border-top-left-radius: 0px;
	border-top-right-radius: 0px;
	border-bottom-left-radius: 150px;
	border-bottom-right-radius: 150px;
	color: #fff;
	align-items: center;
	cursor: pointer;
	margin: -16px auto 20px auto;
	position: relative;
	justify-content: center;
	display: flex;
	flex-direction: column;
	text-overflow: ellipsis;
	white-space: nowrap;
	overflow: hidden;
	font-size: 14px;
	text-align: center;
}
.xiala1{
	background-color: #0f66e0;
	border-bottom: solid 1px #0f66e0;
	border-left: solid 1px #0f66e0;
	border-right: solid 1px #0f66e0;
}

.xiala2{
	background-color: #5e87c1;
	border-bottom: solid 1px #5e87c1;
	border-left: solid 1px #5e87c1;
	border-right: solid 1px #5e87c1;
}
	.search-ipu-goods{
		padding: 0px 5px;
		flex: 1;
		min-height: 30px;
		justify-content: center;
		display: flex;
		margin: auto 0px;
		color: #1b1b1b;
		text-align: center;
		background-color: #fff;
		font-size:14px;
		min-width: 100px;
		border-left: #33333300;
		text-align: left;
		height: 100%;
	}
	.goods-info-image{
		display: flex;
		align-items: center;
	}
	.goods-info-image .image-boxs{
		width: 300px;
		float: left;
		position: relative;
	}
	.goods-info-image .image-boxs .images{
		width: 300px;
		height: 200px;
		border: solid 1px #eee;
		border-radius: 8px;
	}
	.add-but-com-0{
		margin: auto 0px;
		border-radius: 8px;
		min-width: 80px;
		text-align: center;
		background-color: #0f66e0;
		color: #fff;
		cursor: pointer;
		height: 30px;
		align-items: center;
		display: flex;
		justify-content: center;
		padding: 0px 5px;
	}
</style>